I have a response that will look like this:
"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":{
}
So I make my POJO class look like this:
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
}
Then I will have a Field2 class that look like this:
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
}
The problem now is I want to know how many array is inside field_2 object. Look like there is no way for me to access the field_2 object.
I try to access it via field2.names() , but it cant resolve.
Therefore someone please help.
What I want is, How many key like array 1, array 2 is existed inside field_2? It will return a value in int. How can I do that?