遍历json
程序员文章站
2022-07-12 15:50:53
...
private void Test() throws JSONException {
JSONObject result = new JSONObject();
result.put("id", "A02");
result.put("name", "steven");
Iterator<?> it = result.keys();
String aa2 = "";
String bb2 = "";
while (it.hasNext()) {// 遍历JSONObject
aa2 = (String) it.next().toString();
bb2 = result.getString(aa2);
}
System.out.println(aa2.toString());
System.out.println(bb2.toString());
}