This is my codes :
JSONObject jsonObject = new JSONObject(response.toString());
JSONObject jsonOb=jsonObject.getJSONObject("LocationMatrix");
Log.e(TAG,"jsonOb :"+jsonOb.toString());
Then print out :
jsonOb :{"45":"NUMANCIA 39-41","44":"DEMESTRE 10","35":"ALIÓ 19","22":"ALFONSO X EL SABIO 8","36":"ROSARI 42","23":"PI I MARGALL 101","33":"MELCHOR DE PALAU 65","24":"ROBRENYO, ESC.A 55","34":"SARDENYA 545","25":"ROBRENYO, ESC.B 55","39":"L´ERAMPPRUNYA 41","26":"ROSSELLO 230","27":" ENRIQUE GIMENEZ 10","37":"CALATRAVA 1-7 E","28":"GRAN VIA CORTS CATALANES 489","38":"AUGUSTA 276","29":"AUTOVIA DE CASTELLDEFELS 135","43":"ROSARIO 37","30":"GANDUXER 72","42":"VALLDEMOSA 64","41":"VALLDEMOSA 62","32":"CONSELL DE CENT 97","40":"VALLDEMOSA 60","31":"SANTA AMELIA 22"}
How to make custom ArrayList using JsonObject values?
For Example :
for (int i = 0; i < jsonOb.length(); i++) {
int mId = intValue;
String mTitle = StringValue;
locationList.add(new Location(mId, mTitle));
}
Where LocationList is one kind of custome ArrayList<Location>.
and Location is one kind of class which parameters id, title.