gpt4 book ai didi

android - 使用 Retrofit 解析数组内的动态数组

转载 作者:太空狗 更新时间:2023-10-29 13:18:01 24 4
gpt4 key购买 nike

我正在尝试使用 Retrofit 解析以下数据结构,它在另一个动态数组集合中包含动态数组集合。

模型类是否正常或服务器响应有问题?

结构#

{
"DATA": {
"2015": [
[

],
[

],
[

],
[

],
[

],
[
{
"fAmount": "1000",
"paydate": "07\/29\/2015",
"vName": "Mr. mule",
"vPropertyStreet": "Street light",
"vPropertyState": "test2",
"vPropertyZipcode": "2222222",
"vPropertyCity": "test2",
"type": "Credit",
"vPdfURL": "url"
},
{
"fAmount": "1000",
"paydate": "07\/29\/2015",
"vName": "new",
"vPropertyStreet": "Street light",
"vPropertyState": "test2",
"vPropertyZipcode": "2222222",
"vPropertyCity": "test2",
"type": "Charge",
"vPdfURL": "url"
},
{
"fAmount": "1000",
"paydate": "07\/29\/2015",
"vName": "Mr. mule",
"vPropertyStreet": "Street light",
"vPropertyState": "test2",
"vPropertyZipcode": "2222222",
"vPropertyCity": "test2",
"type": "Credit",
"vPdfURL": "url"
}
],
[

],
[

],
[

],
[

],
[

],
[

]
]
},
"SUCCESS": 1
}

错误#

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT

尝试过#

public class DataModelUserStatement {
@SerializedName("DATA")
Map<String, List<DataModelUserStatementSub>> types;

Integer SUCCESS;

String MESSAGE;

public Map<String, List<DataModelUserStatementSub>> getTypes() {
return types;
}

public void setTypes(Map<String, List<DataModelUserStatementSub>> types) {
this.types = types;
}

public Integer getSUCCESS() {
return SUCCESS;
}

public void setSUCCESS(Integer SUCCESS) {
this.SUCCESS = SUCCESS;
}

public String getMESSAGE() {
return MESSAGE;
}

public void setMESSAGE(String MESSAGE) {
this.MESSAGE = MESSAGE;
}
}

 public class DataModelUserStatementSub {
Map<String, List<Type>> types;


public Map<String, List<Type>> getTypes() {
return types;
}

public void setTypes(Map<String, List<Type>> types) {
this.types = types;
}
}

public class Type {
@SerializedName("fAmount") private String fAmount;
@SerializedName("paydate") private String paydate;
@SerializedName("vName") private String vName;
@SerializedName("vPropertyStreet") private String vPropertyStreet;
@SerializedName("vPropertyState") private String vPropertyState;
@SerializedName("vPropertyZipcode") private String vPropertyZipcode;
@SerializedName("vPropertyCity") private String vPropertyCity;
@SerializedName("type") private String type;
@SerializedName("vPdfURL") private String vPdfURL;


public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getvPdfURL() {
return vPdfURL;
}

public void setvPdfURL(String vPdfURL) {
this.vPdfURL = vPdfURL;
}

public String getfAmount() {
return fAmount;
}

public void setfAmount(String fAmount) {
this.fAmount = fAmount;
}

public String getPaydate() {
return paydate;
}

public void setPaydate(String paydate) {
this.paydate = paydate;
}

public String getvName() {
return vName;
}

public void setvName(String vName) {
this.vName = vName;
}

public String getvPropertyStreet() {
return vPropertyStreet;
}

public void setvPropertyStreet(String vPropertyStreet) {
this.vPropertyStreet = vPropertyStreet;
}

public String getvPropertyState() {
return vPropertyState;
}

public void setvPropertyState(String vPropertyState) {
this.vPropertyState = vPropertyState;
}

public String getvPropertyZipcode() {
return vPropertyZipcode;
}

public void setvPropertyZipcode(String vPropertyZipcode) {
this.vPropertyZipcode = vPropertyZipcode;
}

public String getvPropertyCity() {
return vPropertyCity;
}

public void setvPropertyCity(String vPropertyCity) {
this.vPropertyCity = vPropertyCity;
}
}

最佳答案

最终我实现了它的工作,但模型类存在问题。

我们只需要使用下面两个模型类。


DataModelUserStatement.class

public class DataModelUserStatement {
@SerializedName("DATA")
Map<String, List<List<Type>>> types;

Integer SUCCESS;

String MESSAGE;

public Map<String, List<List<Type>>> getTypes() {
return types;
}

public void setTypes(Map<String, List<List<Type>>> types) {
this.types = types;
}

public Integer getSUCCESS() {
return SUCCESS;
}

public void setSUCCESS(Integer SUCCESS) {
this.SUCCESS = SUCCESS;
}

public String getMESSAGE() {
return MESSAGE;
}

public void setMESSAGE(String MESSAGE) {
this.MESSAGE = MESSAGE;



}
}

和我在问题中发布的类型

关于android - 使用 Retrofit 解析数组内的动态数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32494544/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com