I am using an efficient network library upgrade, but I was not able to process Dynamic JSON, which contains one responseMessage prefix that accidentally changes to object , the same prefix ( responseMessage ) in some cases changes to String (dynamically).
Json format responseMessage Object:
{ "applicationType":"1", "responseMessage":{ "surname":"Jhon", "forename":" taylor", "dob":"17081990", "refNo":"3394909238490F", "result":"Received" } }
responseMessage The Json format is dynamically changed to a string like:
{ "applicationType":"4", "responseMessage":"Success" }
The problem for me is that the modification has built-in JSON parsing, we must assign one POJO per request! but the REST-API, unfortunately, is built with dynamic JSON responses, the prefix will randomly change to a string per object in both Success (...) and failure (...) !
void doTrackRef(Map<String, String> paramsref2) { RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint("http://192.168.100.44/RestDemo").build(); TrackerRefRequest userref = restAdapter.create(TrackerRefRequest.class); userref.login(paramsref2, new Callback<TrackerRefResponse>() { @Override public void success( TrackerRefResponse trackdetailresponse, Response response) { Toast.makeText(TrackerActivity.this, "Success", Toast.LENGTH_SHORT).show(); } @Override public void failure(RetrofitError retrofitError) { Toast.makeText(TrackerActivity.this, "No internet", Toast.LENGTH_SHORT).show(); } }); }
Pojo:
public class TrackerRefResponse { private String applicationType; private String responseMessage;
In the POJO TrackerRefResponse.java code above, the responseMessage prefix is set to a string or object of type responseMessage, so we can create a POJO with the ref variable with the same name (java basics :)), so I'm looking for the same solution for dynamic JSON in "Retrofit" . I know that this is a very simple job in regular http clients with an asynchronous task, but this is not the best practice in analyzing REST-Api JSON ! looking at Benchmarks performance, Volley or Retrofit is always the best choice, but I could not cope with the JSON dynamics!
Possible solution that I know
Use the old asyc task with parsing the http client. :(
Try to convince the RESTapi database developer.
Create a custom client for retooling :)