JSONArray cannot be converted to JSONObject error

Change

JSONObject data = jsonObj.getJSONObject("data"); 

to

JSONArray data = jsonObj.getJSONArray("data");

As value of data is JsonArray not JSONObject.

And to Get individual Ids and Field Names, you should loop through this JSONArray, as follows:

for(int i=0; i<data.length(); i++)
{
     JSONObject obj=data.getJSONObject(i);
     String id = obj.getString("Id"); 
        String value = obj.getString("FieldName"); 
        Log.d("Item name: ", value);
}

Leave a Comment