java - Convert JsonObject array to integer -


i getting following response server:

{"subjectname":["irish","maths","english","science","religion","geography"], "subjectid":[1,2,3,4,5,6]} 

what need try separate response 2 separate arrays subjectname , subjectid.

here have:

 try {             jsonarray = jsonobject.getjsonarray("subjectname");         } catch (jsonexception e) {             e.printstacktrace();         }         subjectname = new string[jsonarray.length()];         (int = 0; < jsonarray.length(); i++)         {             try {                 subjectname[i] = jsonarray.getstring(i);             } catch (jsonexception e) {                 e.printstacktrace();             }         }          try         {             jsonarray = jsonobject.getjsonarray("subjectid");             log.v("worked", "subjectid in ");          } catch (jsonexception e)         {             log.v("failed","not able retrieve data");             e.printstacktrace();         }         subjectid = new int[jsonarray.length()];         (int = 0; < jsonarray.length(); i++)         {              try {                 subjectid[i] = jsonarray.getint(i);             } catch (jsonexception e)             {                 e.printstacktrace();               }         } 

the string seems convert no problem , can subjectname subjectid part seems fail , have no idea why. i've checked , can't seem find anywhere shows me how parse int jsonaray.

you using wrong node name.

replace

jsonarray = jsonobject.getjsonarray("subjectid"); 

with

jsonarray = jsonobject.getjsonarray("subjectid"); 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -