I am getting response from API, in that if there is data present then it is returning object and when data is not present it is returning blank array. I have model class for serializing this. Here is model class
@SerializedName("local")
public Local _local = new Local();
public class Local{
@SerializedName("total")
public String _total;
@SerializedName("providers")
public ArrayList<ProvidersDetails> _providers = new ArrayList<>();
public class ProvidersDetails{
@SerializedName("id")
public String _id;
@SerializedName("image")
public String _image;
}
@SerializedName("admin")
public transient Admin admin = new Admin();
public class Admin{
@SerializedName("id")
public String _id;
@SerializedName("first_name")
public String _first_name;
@SerializedName("last_name")
public String _last_name;
}
@SerializedName("orgn")
public Organization _organization = new Organization();
public class Organization{
@SerializedName("name")
public String _ name;
}
}
Here is some part of response i am getting from api
"local":{
"providers":[
{
"id":"1180",
"image":"photo.png"
},
{
"id":"1180",
"image":"photo.png"
},
{
"id":"1180",
"image":"photo.png"
}
],
"admin":{
"id":"1180",
"first_name":"nqgnerq",
"last_name":"gnejbeqp",
},
"orgn":{
"name":"organization name"
}
}
here is the other form which i am getting when data is not present
"local":{
"total":0,
"providers":[
],
"admin":[
],
"orgn":{
"name":"organization name"
}
}
I have checked many work arounds but failed, as i want to handle it in my pojo class. DO any one have solution, please suggest.