Parse foursquare json response on android
I am trying to parse the JSON file returned by Foursquare API on android.The JSON fle starts like this:
{"meta":{"code":200},"response":{"groups":[{"type":"places","name":"Matching Places","items":[{"id":"4bc5b8056936952188618488","name":"Boots Clifton Down","contact":{},
and here is my function so far:
private void tokenize(String output){
try {
JSONObject json = new JSONObject(output);
JSONArray venues = json.getJSONObject("response").getJSONObject("groups").getJSONArray("items");
System.out.println(venues.length());
} catch (JSONException e) {
e.printStackTrace();
}
}
I tried replacing
JSONArray venues = json.getJSONObject("response").getJSONObject("groups").getJSONArray("items");
with
JSONArray venues = json.getJSONObject("response").getJSONArray("groups").getJSONArray("items");
but I开发者_运维问答 keep getting
org.json.JSON.typeMismatch(JSON.java:96)
I am trying to create a JSONArray from the items
array. How can I accomplish this?
Thanks in advance
I think you mean
JSONArray venues = json.getJSONObject("response")
.getJSONArray("groups")
.getJSONObject(0)
.getJSONArray("items");
精彩评论