java - Android How to get array from a single key -
this question has answer here:
- how parse jsonarray in android 3 answers
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
Post a Comment