[英]java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2
I am using Retro Fit
to connect to API online.我正在使用
Retro Fit
在线连接到 API。 But I am getting this error while trying to parse the returned data.但是在尝试解析返回的数据时出现此错误。
retrofit.RetrofitError: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2
The data being returned is in This format and model for data is also given below:返回的数据采用这种格式,数据模型也如下所示:
iGPlaceApi.getStreams(ITEMS_PER_PAGE, pageNumber * ITEMS_PER_PAGE, new Callback<List<mGooglePlacesApiResponse>>() {
@Override
public void success(List<mGooglePlacesApiResponse> mGp, Response response) {
int n = mGp.size();
Object asa = mGp.toArray();
}
@Override
public void failure(RetrofitError retrofitError) {
String error = retrofitError.toString();
}
});
public class mGooglePlacesApiResponse {
public String html_attributions;
//public List<String> html_attributions;
public String next_page_token;
public List<place> results;
}
public class place {
public Geometry geometry;
public String icon;
public String id;
public String name;
public OpeningHours opening_hours;
public List<Photo> photo
...
Change List<mGooglePlacesApiResponse> mGp
to mGooglePlacesApiResponse mGp
.将
List<mGooglePlacesApiResponse> mGp
更改为mGooglePlacesApiResponse mGp
。 Your JSON contains object not list.您的 JSON 包含对象而不是列表。
@edit @编辑
Btw, html_attributions is an array顺便说一句,html_attributions 是一个数组
@edit2 @编辑2
Well, i see you corrected your html_attrubutions嗯,我看到你更正了你的 html_attrubutions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.