java - Parsing JSON Data (Android) -


alright. have json object sent me server contains following data:

{     "result":     [         {"status":"green","type":"data1"},         {"status":"green","type":"data2"},         {"status":"green","type":"data3"}     ],     "status":"ok" } 

the data want status 3 status values. data1, data2, , data3 show in order, i'm trying grab data index (e.g. data1 = index 0, data2 = index 1, data3 = index 2). how do that?

try following:

string stat1; string stat2; string stat3; jsonobject ret; //contains original response //parse value try {     stat1 = ret.getjsonarray("results").getjsonobject(0).getstring("status");     stat2 = ret.getjsonarray("results").getjsonobject(1).getstring("status");     stat3 = ret.getjsonarray("results").getjsonobject(2).getstring("status"); } catch (jsonexception e1) {     e1.printstacktrace();  } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -