I am making an http call using the new 2.0 modification, and getting a callback, I want to use the gson 2.0 library to parse this json obj and be able to do
jsonData.sector[2].sectorOne
this is my callback:
retrofitApi.Factory.getInstance().getCallData().enqueue(new Callback<ResponseBody>() { @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { try { } catch (IOException e) { e.printStackTrace(); } } @Override public void onFailure(Call<ResponseBody> call, Throwable t) { Log.d("myLogs", "failed to Retrive Data"); Log.d("myLogs", "becouse: "+t); largeTextVar.setText("failed: " + t); } });
so my callback will look like
{ "data": { "sector": [ [ { "scanned": false, "sectorOne": "", "sectorTwo": "", "sectorThree": "" }, { "scanned": false, "sectorOne": "", "sectorTwo": "", "sectorThree": "" } ] ] }, "curserLocation": { "elevation": 30, "horizontal": 105 } }
I use:
compile 'com.squareup.retrofit2:retrofit:2.0.1' compile 'com.squareup.retrofit2:converter-gson:2.0.1'
I searched everywhere how to do it, but I could not find a simple solution for this, what is the easiest and easiest way to achieve this?
json android gson retrofit
Chief madog
source share