org.json.JSONException: employeeLst 没有值
org.json.JSONException: No value for employeeLst
我正在尝试解析一个 JSON 数组,但我得到了 employeeLst 的无值 Error.I 已尝试
所有组合。
JSON
{"response": {
"status": "success",
"data": {"employeeLst": [
{
"employeeID": 1,
"name": "Diwakar",
"year": "2015",
"employeeDate": "Nov 21, 2015"
},
{
"employeeID": 2,
"name": "Ponni",
"year": "2015",
"employeeDate": "Nov 21, 2015"
},
{
"employeeID": 3,
"name": "Mahashi",
"year": "2015",
"employeeDate": "Nov 21, 2015"
},
{
"employeeID": 4,
"name": "Ganesh",
"year": "2015",
"employeeDate": "Nov 21, 2015"
},
{
"employeeID": 5,
"name": "Namarata",
"year": "2015",
"employeeDate": "Nov 21, 2015"
}
]}
}}
Code
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
employees = jsonObj.getJSONArray("emplyeeLst");
在上面的行中抛出一个错误,提示 employeeLst.Please 没有值 share the code in Android.
试试这个:
employees = jsonObj.getJSONObject("response").getJSONObject("data").getJSONArray("employeeLst");
我正在尝试解析一个 JSON 数组,但我得到了 employeeLst 的无值 Error.I 已尝试 所有组合。
JSON
{"response": {
"status": "success",
"data": {"employeeLst": [
{
"employeeID": 1,
"name": "Diwakar",
"year": "2015",
"employeeDate": "Nov 21, 2015"
},
{
"employeeID": 2,
"name": "Ponni",
"year": "2015",
"employeeDate": "Nov 21, 2015"
},
{
"employeeID": 3,
"name": "Mahashi",
"year": "2015",
"employeeDate": "Nov 21, 2015"
},
{
"employeeID": 4,
"name": "Ganesh",
"year": "2015",
"employeeDate": "Nov 21, 2015"
},
{
"employeeID": 5,
"name": "Namarata",
"year": "2015",
"employeeDate": "Nov 21, 2015"
}
]}
}}
Code
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
employees = jsonObj.getJSONArray("emplyeeLst");
在上面的行中抛出一个错误,提示 employeeLst.Please 没有值 share the code in Android.
试试这个:
employees = jsonObj.getJSONObject("response").getJSONObject("data").getJSONArray("employeeLst");