开发者

Parse foursquare json response on android

开发者 https://www.devze.com 2023-02-13 12:00 出处:网络
I am trying to parse the JSON file returned by Foursquare API on android.The JSON fle starts like this:

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消