I am using the retrofit efficient networking library, but I am unable to handle Dynamic JSON which contains single prefix responseMessage which changes to
The accepted answer seemed over complicated for me, I solve it this way:
Call call = client.request(params);
call.enqueue(new Callback() {
@Override
public void onResponse(Response response) {
if (response.isSuccess()) {
Gson gson = new Gson();
ResponseBody repsonseBody = response.body().string();
if (isEmail) {
EmailReport reports = gson.fromJson(responseBody, EmailReport.class);
} else{
PhoneReport reports = gson.fromJson(repsonseBody, PhoneReport.class);
}
}
}
@Override
public void onFailure(Throwable t) {
Log.e(LOG_TAG, "message =" + t.getMessage());
}
});
This is just an example in attempt to show you how you can use different model.
The variable isEmail is just a boolean for your condition to use the appropriate model.