[java]代码库
JSONObject obj = new JSONObject(json.toString());
JSONArray obj2 = obj.getJSONArray("cityInfo");
得到集合后遍历就可得到一个JSONObject,再调用getString("name"); 就行了,下面是完整的代码
[java] view plaincopy
JSONObject obj = new JSONObject(json.toString());
JSONArray obj2 = obj.getJSONArray("cityInfo");
for (int i = 0; i < obj2.length(); i++) {
JSONObject temp = new JSONObject(obj2.getString(i));
System.out.println(temp.getString("cityId"));
System.out.println(temp.getString("cityName"));
}
System.out.println("============所在省份为=================");
System.out.println(obj.getString("name"));
//源代码片段来自云代码http://yuncode.net