Skip to content Skip to sidebar Skip to footer

Parsing Json Into Jsonarray

My PHP successfully returns JSON from my SQL table. But my Android code stores it all in one String. Should it indeed be stored in one string and then parsed out into multiple obje

Solution 1:

Yes, this is correct. You need to parse it as JSONArray, as that's what it is. For example (ignoring exceptions etc.):

JSONArray jarr = new JSONArray(jsonString);
for (int i = 0; i < jarr.length(); ++i) {
    JSONObject jobj = jarr.getJSONObject(i);
    // work with object
}

Post a Comment for "Parsing Json Into Jsonarray"