简体   繁体   中英

How can I parse this syntax of JSON?

I've been trying to parse this portion of JSON output, but I cannot figure out how to. I'm trying to pull out " 140 New Montgomery St ". Can anyone tell me how? Below I will include the JSON and my already working JSON parsing code.

{
    "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();
    //...
    //...
}
JSONObject location = business.getJSONObject("location");
JSONArray address = location.getJSONArray("address"); 
String address1 = address.get(0);
//...
//...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM