欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

遍历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());
}