java - How to parse simple JSON Array in android? -


i've been wondering how parse json array in android ?

i've json object this: [{"id":"1","email":"email@mail.mail","password":"password"},{"id":"2","email":"test@test.com","password":"passward"}]

but cannot find how parse it, want access data have first mail, or second id.

i've try around 40 differents solutions, no luck.

last time tried this:

private void showjson(string json){         try {             jsonarray jarray = new jsonarray(json);             string jsonstring = jarray["id"];             tv.append(jsonstring);          } catch (jsonexception e) {e.printstacktrace();}     } 

but expected array , not json array. still haven't found how convert array.

i've tried this:

for (int = 0; < jsonarray.length(); i++) {     jsonobject jsonobject = jsonarray.getjsonobject(i);     string name = jsonobject.getstring("email"); } 

but getjsonobject doesn't exist.

thank help.

try

private void showjson(string json){     try{     jsonarray jsonarray = new jsonarray(json);      (int = 0; < jsonarray.length(); i++) {         string id[i] = jsonarray.getjsonobject(i).getstring("id");        string email[i] = jsonarray.getjsonobject(i).getstring("email");      }      }     catch (jsonexception e) {                 // log.d("jsonexception", e.tostring());             }      } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -