json - Nested JSONArray Record Parsing Issue Android -


i making app receives json data server, user select value spinner 0,1,2... , on, on basis of number selection json return data user defined index 0,1.. don't know how parse inner json data in android

json = new jsonobject(jsonparser.result); jsonarray jarray = json.getjsonarray("data"); stopelement _stop = new stopelement(); log.d("json algo result", json.tostring());  if (jarray!=null) {     (int = 0; < jarray.length(); i++) {         jsonarray = jarray.getjsonarray(i);         if (jsonarray != null) {             (int j = 0; j < jsonarray.length(); i++){                 if(i==0) {                     jsonarray = jarray.getjsonarray(j);                     _stop.setname(jsonarray.getstring(0));                     stopelement.stop_name_list.add(_stop.getname());                 }              }         } else {             break;         }     } } else {     return null; }      **json data**  [[["sadiqabad chowk","33.634525","73.074326","suzk1"],["chungi no 8","33.627262","73.093567","suzk1"],["jahaz ground","33.628395","73.101936","suzk1"],["khana bridge","33.629967","73.112823","suzk1"],["kuri road","33.643162","73.102928","21"],["faizabad","33.663212","73.084801","21"]],[["sadiqabad chowk","33.634525","73.074326","suzk1"],["petrol pump","33.634109","73.076363","suzk1"],["chandni chowk","33.631584","73.072563","suzk1"],["rahmanabad","33.639065","73.075714","3"],["passport office","33.642410","73.076981","3"],["shamsabad","33.650101","73.079994","3"],["faizabad","33.663212","73.084801","3"]],[["sadiqabad chowk","33.634525","73.074326","suzk1"],["chungi no 8","33.627262","73.093567","suzk1"],["jahaz ground","33.628395","73.101936","suzk1"],["khana bridge","33.629967","73.112823","suzk1"],["zia masjid","33.637196","73.107407","124-a"],["kuri road","33.643162","73.102928","124-a"],["dhok kala khan","33.653118","73.095444","124-a"],["faizabad","33.663212","73.084801","124-a"]],[["sadiqabad chowk","33.634525","73.074326","suzk1"],["chungi no 8","33.627262","73.093567","suzk1"],["jahaz ground","33.628395","73.101936","suzk1"],["khana bridge","33.629967","73.112823","suzk1"],["zia masjid","33.637196","73.107407","136"],["kuri road","33.643162","73.102928","136"],["iqbal town","33.644279","73.100113","136"],["dhok kala khan","33.653118","73.095444","136"],["faizabad","33.663212","73.084801","136"]],[["sadiqabad chowk","33.634525","73.074326","suzk13"],["dhok ali akbar","33.636997","73.092117","suzk13"],["highway stop","33.679722","73.075584","suzk13"],["bhinder","33.556244","73.167946","suzk3"],["lohi bher","33.586273","73.145493","124"],["wild life park","33.578770","73.132309","124"],["airport chowk","33.593803","73.139938","124"],["gangal","33.612591","73.125801","124"],["khana bridge","33.629967","73.112823","124"],["zia masjid","33.637196","73.107407","124"],["kuri road","33.643162","73.102928","124"],["dhok kala khan","33.653118","73.095444","124"],["faizabad","33.663212","73.084801","124"]],[["sadiqabad chowk","33.634525","73.074326","suzk13"],["petrol pump","33.634109","73.076363","suzk13"],["chandni chowk","33.631584","73.072563","suzk13"],["central hospital","33.628784","73.070641","suzk13"],["naz cinema","33.623936","73.067802","suzk13"],["waris khan","33.620728","73.066078","suzk13"],["comittee chowk","33.612946","73.065193","suzk13"],["liaquat bagh","33.606808","73.064835","suzk13"],["marir hassan","33.596905","73.064445","suzk7"],["punjab house","33.592701","73.065453","suzk7"],["jhanda","33.588970","73.076195","suzk7"],["raheemabad","33.599159","73.080048","21"],["airport","33.603565","73.097137","21"],["tajabad","33.601593","73.126213","21"],["koral chowk","33.605282","73.131279","21"],["khana bridge","33.629967","73.112823","21"],["kuri road","33.643162","73.102928","21"],["faizabad","33.663212","73.084801","21"]],[["sadiqabad chowk","33.634525","73.074326","suzk13"],["petrol pump","33.634109","73.076363","suzk13"],["chandni chowk","33.631584","73.072563","suzk13"],["central hospital","33.628784","73.070641","suzk13"],["naz cinema","33.623936","73.067802","suzk13"],["waris khan","33.620728","73.066078","suzk13"],["comittee chowk","33.612946","73.065193","suzk13"],["liaquat bagh","33.606808","73.064835","suzk13"],["medical college","33.602753","73.067200","29"],["sir syed boys school","33.609600","73.078766","29"],["fauji tower","33.606770","73.084106","29"],["chaklala station","33.601013","73.095924","29"],["raheemabad","33.599159","73.080048","29"],["airport","33.603565","73.097137","21"],["tajabad","33.601593","73.126213","21"],["koral chowk","33.605282","73.131279","21"],["khana bridge","33.629967","73.112823","21"],["kuri road","33.643162","73.102928","21"],["faizabad","33.663212","73.084801","21"]],[["sadiqabad chowk","33.634525","73.074326","suzk13"],["petrol pump","33.634109","73.076363","suzk13"],["chandni chowk","33.631584","73.072563","suzk13"],["central hospital","33.628784","73.070641","suzk13"],["naz cinema","33.623936","73.067802","suzk13"]]] 

this work you.

string data= "[[['jahaz ground','33.628395','73.101936','suzk1'],['khana bridge','33.628395','73.101936','suzk1']]]";                 try {                     jsonarray json = new jsonarray(data);                     jsonarray aray = (jsonarray)json.get(0);                     for(int =0; i< aray.length();i++){                         jsonarray object = (jsonarray)aray.get(i);                         string title = (string)object .get(0);                         string lat = (string)object.get(1);                         string lng = (string)object.get(2);                         string com = (string)object.get(3);                     }                 } catch (jsonexception e) {                     e.printstacktrace();                 } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -