Skip to content Skip to sidebar Skip to footer

Parsing Json Array Of Objects In Android

I want to get the lineId, destinationName and timeToStation from this api call https://api.tfl.gov.uk/Line/25,86,w19/Arrivals?stopPointId=490009219W&app_id=&app_key= Can so

Solution 1:

First be sure you have retrieved JSON String,

Then You can easily access the properties inside them like

try {
     JSONArray jsonArray = newJSONArray(json);
     JSONObject obj = jsonArray.getJSONObject(0); //0 for just retrieving first object you can loop itString myVehicleID = obj.getString("vehicleId"); //To retrieve vehicleId//Similarly do it for others as well
    } catch (JSONException e) {
      e.printStackTrace();
    }

Post a Comment for "Parsing Json Array Of Objects In Android"