java需要BEGIN数组,但在第1行和第2行是BEGIN_对象
这是来自api的json数组数据/json对象数据,获取错误预期为begin_数组,但在第3行和第2列路径处为begin_对象$
这是来自api的json数组数据/json对象数据,获取错误预期为begin_数组,但在第3行和第2列路径处为begin_对象$
这是来自api的json数组数据/json对象数据,获取错误预期为begin_数组,但在第3行和第2列路径处为begin_对象$
这是来自api的json数组数据/json对象数据,获取错误预期为begin_数组,但在第3行和第2列路径处为begin_对象$
"offersdata": [
{
"offercode": "GRAB20",
"title": "Get Upto",
"description": "20% off on selected merchandise on purchase of INR 1000 or more"
},
{
"offercode": "JAN20",
"title": "Get Upto",
"description": "20% Off on all purchases in January"
},
{
"offercode": "BHHH",
"title": "DES",
"description": "FDSFS"
}
],
"message": "success"
}
@GET("user")
Call<List<limitedoffers>> getoffers();
package com.example.medico.models;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class limitedoffers {
@SerializedName("offersdata")
@Expose
private List<Offersdatum> offersdata = null;
@SerializedName("message")
@Expose
private String message;
public List<Offersdatum> getOffersdata() {
return offersdata;
}
public void setOffersdata(List<Offersdatum> offersdata) {
this.offersdata = offersdata;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package com.example.medico.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Offersdatum {
@SerializedName("offercode")
@Expose
private String offercode;
@SerializedName("title")
@Expose
private String title;
@SerializedName("description")
@Expose
private String description;
public String getOffercode() {
return offercode;
}
public void setOffercode(String offercode) {
this.offercode = offercode;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
# 1 楼答案
啊,这是我最喜欢的话题
要解决这个问题,您必须实现serializer
对于您的情况,您必须自己将即将到来的对象转换为数组
# 2 楼答案
我已经完整地阅读了关于改型的内容,改型将在阵列完全序列化时起作用
在上面的Jsonarray中,offersdata具有ArrayList
在接口类中,必须更改此代码
对这个
因为它不包含ArrayList
要在响应后从限制提供程序获取数组,只需使用
获取报价数据Arraylist