I am working on an android app that get json content of a webservice called \"WebUntis\". The Json content i am getting looks like:
{\"jsonrpc\":\"2.0\",\"id
This is another way to do it...
call.enqueue(new Callback() {
@Override
public void onResponse(Call call,
Response response) {
JSONObject jsonObject;
try {
jsonObject = new JSONObject(new Gson().toJson(response.body()));
JSONArray returnArray = jsonObject.getJSONArray("my_array");
// Do Work Only If Not Null
if (!returnArray.isNull(0)) {
for (int l = 0; l < returnArray.length(); l++) {
if (returnArray.length() > 0) {
// Get The Json Object
JSONObject returnJSONObject = returnArray.getJSONObject(l);
// Get Details
String imageUrl = returnJSONObject.optString("image");
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Call call,
Throwable t) {
}
});