0

How would I iterate trough this JSON string that is in a JSONObject?:

[
   {"Suggestion": "Roosendaal"},
   {"Suggestion": "Rucphen"},
   {"Suggestion": "Rijsbergen"},
   {"Suggestion": "Rijen"},
   {"Suggestion": "Raamsdonksveer"},
   {"Suggestion": "Raamsdonk"},
   {"Suggestion": "Rijswijk NB"}
]
Cœur
  • 34,719
  • 24
  • 185
  • 251
Wesley Egbertsen
  • 700
  • 8
  • 22
  • This is `JSONArray`, you could iterate it as simple Array, Have a look at [JSON Array iteration in Android/Java](http://stackoverflow.com/a/6376083/593709) – Adil Soomro Sep 30 '13 at 13:55

1 Answers1

0

I suppose you are using org.json for that.

JSONArray array = new JSONArray(s);
int length = array.length();
for (int i = 0; i < length; i++) {
    JSONObject o = array.getJSONObject(i);
    System.out.println(o);
}

Where s is your String.

Dan D.
  • 32,096
  • 5
  • 61
  • 79