public static void parseProfilesJson(String the_json){
try {
JSONObject myjson = new JSONObject(the_json);
JSONArray nameArray = myjson.names();
JSONArray valArray = myjson.toJSONArray(nameArray);
for(int i=0;i<valArray.length();i++)
{
String p = nameArray.getString(i) + "," + ValArray.getString(i);
Log.i("p",p);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
As you can see, this sample code will print out the KEY of the JSONs, followed by the VALUES of the JSONS.
It would print profiles, john if the json was like this:
{'profiles':'john'}
That's cool. That's fine, as I can work with those variables. However, what if the JSON was like this:
{'profiles': [{'name':'john', 'age': 44}, {'name':'Alex','age':11}]}
In this case, the entire value would be the array. Basically, I just want to grab that array (which is the "value" in this case)...and turn it into an actual array that JAVA could use. How can I do that? Thanks.