I want to get a list of friends' names from the Facebook API in Android. In that process, I want to learn how to read JSON objects/Arrays.
I have JSONObject and/or JSONArrays that have been passed to me. I don't know what's in them*. I know how to read the data once I know what fields exist, but I can't read anything as far as I can tell, without a key. Even with the key, How can I tell what's in it?
Basically, I'd like a piece of code that looks like:
JSONArray mArray = response.getJSONArray();
String theEntireDatabase = mArray.getStringOFEntireDatabase();
and have it respond with a String that looks like this:
{
"phoneNumber": [
{
"type": "work",
"num": "11111"
},
{
"type": "home",
"num": "2222"
}
],
"address": {
"state": "World",
"address": "infinite space, 000",
"city": "Android city"
},
"surname": "Swa",
"name": "Android"
}
Having known nothing of what is in the database beforehand?
*it could be "color:" it could be "nuclear threat level:" for all I know.
I tried this, but it only gives keys: Javascript get JSON key Name