read json data in java -


i'm in situation have read json data , insert sqlite table. json data in format :

{     "result": "success",     "data": {         "userid": "873",         "volume": "0.5",         "schoolid": "0",         "schoolname": "",         "preferredlanguageid": "1",         "fname": "robin",         "lname": "singh",         "email": "rob@live.com",         "password": "password1111",         "isparent": "0",         "countryid": "254",         "stateid": "143",         "state": "",         "city": "san diego",         "coins": "0",         "zip": "",         "players": []     } }  jsonobject json = new jsonobject(jsonstring); string uname=json.getstring("fname"); 

but i'm not able first name in string uname.

string uname=json.getstring("fname"); 

is not working because fname property nested within data property. therefore need following:

string uname = json.getjsonobject("data").getstring("fname"); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -