I am trying to finish up part of my Android application that enables the user to enter a URL, and pull the JSON array data from it. Currently the application takes the users URL, and stores the string as something that looks like this:
{
"name": "Demo",
"currentdistance": "0",
"goals": [
{
"goal": {
"depth": "2",
"goal": "2"
},
"goal": {
"depth": "6",
"goal": "4"
},
"goal": {
"depth": "4",
"goal": "3"
}
}
]
}
Now I have found many solutions (such as this) that work great, but they assume that you know ahead of time what the key values are. I am trying to make a JSON array from a source that is not known at compile time, and could range from one key to many.
I have tried just saving the string as a JSON object, then using .put
to add it to an array, but that is not much use if the data has more than one key. I have to be able to parse and treat is like a true JSON array once I have gotten the data from the URL.
I am not concerned about error checking on the URL right now, so just assume the URL given to the app is a proper HTTP JSON text like shown above.
Any help would be appreciated!