json - Android : How to access a JSONObject -


i'm new android , have tried many options access jsonobject returns api call couldn't succeed of solutions looked didn't work me.

what want access jsonobject , keep id & name in array. , populate names in autocompletetextview. how access jsonobject. please me this. i'm stuck on more day.

following code handling jsonobject.

@override public void processfinish(jsonobject output) {     toast.maketext(mainactivity.this,"processfinish",toast.length_short).show();     allstations = output;      if(output != null){         toast.maketext(mainactivity.this,output.tostring(),toast.length_short).show();        }else{         toast.maketext(mainactivity.this," connection failed!",toast.length_short).show();     } } 

following sample output of jsonobject

{     "success": true,     "message": "found 398 results!",     "nofresults": 3,     "results": {         "stationlist": [             {                 "stationcode": "abn",                 "stationid": 3,                 "stationname": "abla"             },             {                 "stationcode": "adla",                 "stationid": 410,                 "stationname": "adla"             },             {                 "stationcode": "anm",                 "stationid": 11,                 "stationname": "ahama"             }]     },     "statuscode": "2000" } 

try

try { jsonobject obj= output.getjsonobject("results");  jsonarray dataarray= obj.getjsonarray(“stationlist“);  for(int i=0;i<dataarray.length();i++)
{
     jsonobject object1=dataarray.getjsonobject(i);     strind id = object1.getstring("stationid"); } } catch (jsonexception e) {
     e.printstacktrace();
 } 

in code output jsonobject result


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -