I am having trouble understanding how can I loop through a JSONArray like this one----- [ {"A": "a", "X": "x"}, {"A": "a1", "X": "x1"}, {"A": "a2", "X": "x2"} {"A": "a3", "X": "x3"} ] Any help would be greatly appreciated.
Asked
Active
Viewed 63 times
-1
-
2try writing some code. – Scary Wombat Feb 10 '16 at 02:40
1 Answers
0
JSONArray a = ...;
for (int i = 0; i < a.length(); i++) {
JSONObject o = a.getJSONObject(i);
// do something with o
}

Doug Stevenson
- 297,357
- 32
- 422
- 441
-
Thanks, I was confused between accessing JSONObject/JSONArray. You cleared the doubt. – user5890847 Feb 10 '16 at 03:10
-
Yeah, the JSONObject API is kind of dense and not the greatest to work with. – Doug Stevenson Feb 10 '16 at 03:17