parse json array to normal array in android -


i have json data php -it's 1 dimensional array-:

{pair:["-8.5745000,115.3735700","-8.5683300,115.3733700","-8.5683300,115.3733700","-8.5687800,115.3997700","-8.5687800,115.3997700","-8.5764900,115.4007400","-8.5764900,115.4007400","-8.5687800,115.3997700","-8.5687800,115.3997700","-8.5656400,115.4156400","-8.5656400,115.4156400","-8.5565200,115.4122800","-8.5565200,115.4122800","-8.5566200,115.4110500","-8.5566200,115.4110500","-8.5560700,115.4112200","-8.5560700,115.4112200","-8.5554200,115.4112800","-8.5554200,115.4112800","-8.5527200,115.4025400","-8.5527200,115.4025400","-8.5424000,115.4027000","-8.5424000,115.4027000","-8.5426600,115.4055800","-8.5426600,115.4055800","-8.5377000,115.4057200","-8.5377000,115.4057200","-8.5375900,115.4034500","-8.5375900,115.4034500","-8.5358900,115.4036500","-8.5358900,115.4036500","-8.5358800,115.4033400"]} 

and in android want save json array array array this

pair=["-8.5745000,115.3735700","-8.5683300,115.3733700","-8.5683300,115.3733700","-8.5687800,115.3997700","-8.5687800,115.3997700","-8.5764900,115.4007400","-8.5764900,115.4007400","-8.5687800,115.3997700","-8.5687800,115.3997700","-8.5656400,115.4156400","-8.5656400,115.4156400","-8.5565200,115.4122800","-8.5565200,115.4122800","-8.5566200,115.4110500","-8.5566200,115.4110500","-8.5560700,115.4112200","-8.5560700,115.4112200","-8.5554200,115.4112800","-8.5554200,115.4112800","-8.5527200,115.4025400","-8.5527200,115.4025400","-8.5424000,115.4027000","-8.5424000,115.4027000","-8.5426600,115.4055800","-8.5426600,115.4055800","-8.5377000,115.4057200","-8.5377000,115.4057200","-8.5375900,115.4034500","-8.5375900,115.4034500","-8.5358900,115.4036500","-8.5358900,115.4036500","-8.5358800,115.4033400"] 

im trying this

string []pairs=null; string hasil = ""; hasil = getrequest(url); try { jobject = new jsonobject(hasil); jsonarray myarray = jobject.getjsonarray("pair"); for(int = 0; < myarray.length(); i++) { pairs[i]= myarray.get(i).tostring(); } } catch (jsonexception e) { e.printstacktrace(); } teks1 = (textview)findviewbyid(r.id.textview1); teks1.settext(arrays.tostring(pairs)); 

but still didnt work

 arraylist<string> list = new arraylist<string>(); jsonarray jsonarray = (jsonarray)jsonobject; if (jsonarray != null) { int len = jsonarray.length(); (int i=0;i<len;i++){ list.add(jsonarray.get(i).tostring()); } } } string i[] = list.toarray(); //get array 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -