I am using retrofit for rest api calls for my android app development. Since my all api response has "info"
(Note that all api will have same key name) and "data"
(Note that different apis have different key names) parameter, I have used a base class for the api responses. Below are the sample responses from API
Response 1
{
"info":{
"statusCode":200,
"message":"OK"
},
"data":{
"userId":2,
"userName":"riyas"
}
}
Response 2
{
"info":{
"statusCode":200,
"message":"OK"
},
"data":{
"vegId":2,
"vegName":"Potatoa"
}
}
I have created a base class named CloudBaseResponse and was able to get data in response.info
. But I have no idea to parse the **data**
. Please suggest me a way to handle using Retrofit
public class CloudBaseResponse {
public BaseResponse response;
public BaseResponse getResponse() {
return response;
}
public void setResponse(BaseResponse response) {
this.response = response;
}
public class BaseResponse {
public Info info;
}
public class Info{
public String status;
public String message;
}
}