求以下格式Json数组的详细解析代码
{ "results" : [ { "address_components" : [ { "long_name" : "深圳宝安国际机场", "short_name" : "深圳宝安国际机场", "types" : [ "establishment" ] }, { "long_name" : "宝安区", "short_name" : "宝安区", "types" : [ "sublocality", "political" ] }, { "long_name" : "深圳", "short_name" : "深圳", "types" : [ "locality", "political" ] }, { "long_name" : "中国", "short_name" : "CN", "types" : [ "country", "political" ] } ], "formatted_address" : "中国深圳市宝安区深圳宝安国际机场 (SZX)", "geometry" : { "location" : { "lat" : 22.6449180, "lng" : 113.8190080 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 22.65521540, "lng" : 113.83501540 }, "southwest" : { "lat" : 22.63461980, "lng" : 113.80300060 } } }, "types" : [ "airport", "airport", "establishment" ] } ], "status" : "OK"} --------------------编程问答-------------------- 下面代码是我回复其它问题时写的代码,解析JSON的原理是一样的,你参考下面代码自己动手写一下吧.--------------------编程问答-------------------- 楼上的学习了 --------------------编程问答-------------------- http://download.csdn.net/detail/fire_fire_fire/4311626
public static void demo() {
String jsonstr = "{\"info\":[{\"name\":\"123\",\"xy\":111},{\"name\":\"123\",\"xy\":111},{\"name\":\"123\",\"xy\":111}]}";
JSONObject obj;
try {
obj = new JSONObject(jsonstr);
JSONArray array = obj.getJSONArray("info");
for (int i = 0; i < array.length(); i++) {
JSONObject item = (JSONObject) array.get(i);
System.out.println(item.getString("name") + "_________"
+ item.getString("xy"));
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
看看是否对你有帮助
补充:移动开发 , Android