java - Android How to get array from a single key -


this question has answer here:

i don't know how array key value. emails can have more 1 value how can parse emails not jsonarray.

this response:

{     "userid": "377c8a214c",     "username": "princek082+skip@gmail.com",     "emails": [         "princek082+skip@gmail.com",         "upendrasinghktp@gmail.com"     ],     "termsaccepted": "2016-03-03t10:52:14+05:30",     "emailverified": false } 

parse this,

arraylist<string> myemailarray = new arraylist<>();  jsonobject  jsonobj = new jsonobject(yourjson); jsonarray jsonemailarray = jsonobj.getjsonarray("emails"); for(int i=0; i<=jsonemailarray.length(); i++){      myemailarray.add(jsonemailarray.getstring(i)); } 

please let me know if mistakes there, because it's directly written in editor, not tested.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -