org.json.JSONArray cannot be converted to JSONObject

This

JSONObject json = new JSONObject(strResponse);
// your strResponse is a json array 

should be

JSONArray jsonarray = new JSONArray(strResponse);

[ represents json array node

{ represents json object node

for(int i=0; i < jsonarray.length(); i++) {
    JSONObject jsonobject = jsonarray.getJSONObject(i);
    String id       = jsonobject.getString("id");
    String title    = jsonobject.getString("title");
    String company  = jsonobject.getString("company");
    String category = jsonobject.getString("category");
}

Leave a Comment