如何遍历JSONObject

时间:2013-09-30 13:49:53

标签: java json loops

我如何遍历JSONObject中的这个JSON字符串?:

[
   {"Suggestion": "Roosendaal"},
   {"Suggestion": "Rucphen"},
   {"Suggestion": "Rijsbergen"},
   {"Suggestion": "Rijen"},
   {"Suggestion": "Raamsdonksveer"},
   {"Suggestion": "Raamsdonk"},
   {"Suggestion": "Rijswijk NB"}
]

1 个答案:

答案 0 :(得分:0)

我想你正在使用org.json。

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);
}

sString