我一直在尝试解析这部分JSON输出,但我无法弄清楚如何。我正试图推出“ 140 New Montgomery St ”。谁能告诉我怎么样?下面我将包括JSON和我已经工作的JSON解析代码。
{
"businesses" : [{
"display_phone" : "+1-415-908-3801",
"id" : "yelp-san-francisco",
"is_claimed" : true,
"is_closed" : false,
"image_url" : "http://s3-media2.ak.yelpcdn.com/bphoto/7DIHu8a0AHhw-BffrDIxPA/ms.jpg",
"location" : {
"address" : [
"140 New Montgomery St"
],
"city" : "San Francisco",
"neighborhoods" : [
"SOMA"
],
"postal_code" : "94105",
"state_code" : "CA"
},
"mobile_url" : "http://m.yelp.com/biz/4kMBvIEWPxWkWKFN__8SxQ",
"name" : "Yelp",
}
],
"region" : {
"center" : {
"latitude" : 37.786138600000001,
"longitude" : -122.40262130000001
},
"span" : {
"latitude_delta" : 0.0,
"longitude_delta" : 0.0
}
},
"total" : 10651
}
JSONObject json = new JSONObject(rawData);
JSONArray businesses;
businesses = json.getJSONArray("businesses");
for (int i = 0; i < businesses.length(); i++) {
JSONObject business = businesses.getJSONObject(i);
closed = business.get("is_closed").toString();
//...
//...
}
答案 0 :(得分:1)
JSONObject location = business.getJSONObject("location");
JSONArray address = location.getJSONArray("address");
String address1 = address.get(0);
//...
//...