问题描述
我收到的回复如下:
"field_1":{
},"field_2" : {
"array_2": [
{
... all other fields
}
],"array_1": [
{
... all other fields
}
],// here will have 4 array or 5 array,I want to get how many array is inside this object
},"field_3":{
}
所以我让我的POJO类看起来像这样:
public class MyPojo{
@SerializedName("field_1")
@Expose
private Field1 class1;
@SerializedName("field_2")
@Expose
private Field2 class2;
@SerializedName("field_3")
@Expose
private Field3 class3;
// other getter and setter
}
然后我将有一个Field2
类,如下所示:
public class Entities {
@SerializedName("array_1")
@Expose
private List<Array1Item> arraylist1 = null;
@SerializedName("array_2")
@Expose
private List<Array2Item> arraylist2 = null;
@SerializedName("array_3")
@Expose
private List<Array3Item> arraylist3 = null;
//other getter setter
}
现在的问题是我想知道field_2
对象中有多少个数组。看来我无法访问field_2
对象。
我尝试通过field2.names()
访问它,但无法解析。
因此请有人帮忙。
我想要的是,array 1
中存在多少个array 2
,field_2
之类的密钥?它将返回int
中的值。我该怎么办?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)