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
  • 37,241
  • 25
  • 195
  • 267
Wesley Egbertsen
  • 720
  • 1
  • 8
  • 25
  • 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,246
  • 5
  • 63
  • 79