Reputation: 2159
I have an JSON something like:
{
"store":"usa",
"values":["1","2","3","4"];
}
and so I go ahead and get a JSON object for values:
JSONObject values = json.getJSONObject("values");
So now I have this Json object but methods like getName("X") does not work for this type of JSON. There is no key value for the Array now. Its just Strings oen after another.
I want it to return like
String[] listValues = value.getArray();
But I don't see anything like this.
Any ideas ?
Thanks !!
Upvotes: 0
Views: 71
Reputation: 2013
String myJson = "{
"store":"usa",
"values":["1","2","3","4"]
}";
JSONObject jsonObject = new JSONObject(myJson);
JSONArray array = jsonObject.getJSONArray("values");
Upvotes: 0
Reputation: 46
Have you tried this?
JSONArray a = json.getJSONArray("values");
for (int i = 0; i < a.size(); i++) {
Log.d("Type", a.getString(i););
}
Upvotes: 3