I'm in a situation where I have to read the json data and insert it into Sqlite table.
But the json data in this format :
{
"result": "success",
"data": {
"userId": "873",
"volume": "0.5",
"schoolId": "0",
"schoolName": "",
"preferredLanguageId": "1",
"fname": "robin",
"lname": "singh",
"email": "[email protected]",
"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 to get the first name in the string uname.
JSONArray list = (JSONArray) jsonObject.get("data");to get collection of all properties nested within the data property.