如何解析JSON的这种语法?

问题描述:

我一直试图解析这部分的JSON输出,但我不知道如何。我试图拔出“140 New Montgomery St”。谁能告诉我如何?下面我将包括JSON和我已经工作的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(); 
    //... 
    //... 
} 
+1

你得的'location'作为对象及其'address'作为数组。 –

JSONObject location = business.getJSONObject("location"); 
JSONArray address = location.getJSONArray("address"); 
String address1 = address.get(0); 
//... 
//...