引入maven依赖:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
String jsonStr = "{\"浙江\":19,\"上海\":18,\"江苏\":5,\"福建\":6}";
JSONObject jsonObject = new JSONObject(jsonStr);
Iterator iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next().toString();
System.out.println(key + "---->" + jsonObject.get(key));
}
网友评论