org.json.JSONException:employeeLst没有值

时间:2015-01-03 17:39:09

标签: android json

我正在尝试解析JSON数组,我得到了employeeLst Error的No值。我试过了 所有组合。

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的值。请在Android中共享代码。

1 个答案:

答案 0 :(得分:2)

试试这个:

employees = jsonObj.getJSONObject("response").getJSONObject("data").getJSONArray("employeeLst");