purva purva - 3 months ago 7x
JSON Question

Fetching Array from Json server?

my android code

json format

i want to get fetch the lat and long of the Trip1 array???

Drv Drv

Replace your

JSONArray msg=tripObjects.getJSONArray("Trips");
JSONArray msg1=tripObjects.getJSONArray("Trip1");


JSONObject msg=tripObjects.getJSONObject("Trips");
JSONArray msg1=msg.getJSONArray("Trip1");

And fetch your lat-long by using for loop on your msg1 array's size as below:

for(int j=0;j<msg1.length();j++){
     JSONObject msgObject=msg1.getJSONObject(j);
     String lat=msgObject.getString("Sfltlattitude");
     String longi=msgObject.getString("SfltLogitude");