简体   繁体   中英

Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 570

I'm creating an android app using useless access method from Foursquare API. However, I'm using Gson API to retrieve Json and volley. Everything seems to work well, json format had been obtain as I use log.d to track down in my DDMS window. But there is an error com.google.gson.JsonSyntaxException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 570 .

Here is my foursquare API link.

https://api.foursquare.com/v2/venues/explore?client_id=WUZWQOWZ4JOAXKZWDACVODXM3VM3OYPAM3TLYPBLOXVZ01E1&client_secret=XWXSVDQOQ020MKHUG2AY42EOCJCI4JMQE3GIAE3DE3XRKQ32&ll=3.107172,101.476510&section=food&limit=10&v=20130815

ArrayList<FVenue> ven = data.getResponse().getGroups().getItems();
adapter = new RestListAdapter(getActivity(),data.getResponse().getGroups().getItems());
lv.setAdapter(adapter);

Try this:

public class MyResponse extends ArrayList<FVenue> implements Serializable {
//this code assumes you have an FVenue.class which defines the FVenue entity
}

Then when you try to deserialize:

Gson gson = new Gson();
MyResponse data = gson.fromJson("yourjsonstring", MyResponse.class);
//do whatever you want with the data

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