Multiple array json parsing under a object in android [closed]

Use from this link and in doInBackground method you must have these code:

if (jsonStr != null) {
    try {
        JSONObject jsonObj = new JSONObject(jsonStr);


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

        // Getting JSON Array node 
        JSONArray ambulance = jsonObj.getJSONArray("ambulance");
        // looping through All ambulance 
        for (int i = 0; i < ambulance.length(); i++) {
            JSONObject c = contacts.getJSONObject(i);

            String id = c.getString("ID");
            String Title = c.getString("Title");
            String Longitude = c.getString("Longitude");
            String Latitude = c.getString("Latitude");
            String Address = c.getString("Address");
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
} else {
    Log.e("ServiceHandler", "Couldn't get any data from the url");
}

Leave a Comment