【问题标题】:Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 570预期为 BEGIN_OBJECT,但在第 1 行第 570 列为 BEGIN_ARRAY
【发布时间】:2023-03-14 22:50:01
【问题描述】:

我正在使用 Foursquare API 中无用的访问方法创建一个 android 应用程序。但是,我使用 Gson API 来检索 Json 和 volley。一切似乎都运行良好,当我使用 log.d 在我的 DDMS 窗口中追踪时,已经获得了 json 格式。但是有一个错误 com.google.gson.JsonSyntaxException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 570

这是我的foursquare API 链接。

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

【问题讨论】:

    标签: java android json gson


    【解决方案1】:

    试试这个:

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

    然后当你尝试反序列化时:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-08
      • 2016-07-05
      • 2018-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-26
      相关资源
      最近更新 更多