django jsonresponse解析误差Android



这是我从服务器获得的JSON响应:

{
   "0": {
   "pk": 41,
   "fields": {
       "heading": "Empty Lecture Slot",
       "notification": "There is a free lecture available right now for TE B on 2018-05-02 8:00-9:00",
       "date": "2018-04-25",
       "priority": 1,
           "has_read": false,
           "action": "/dashboard/set_substitute/91959"
       },
       "model": "Dashboard.specificnotification"
   }
}

这是用于解析此JSON对象的Java代码:

JSONObject jsonObject = new JSONObject(response);

这是我在捕获块中遇到的错误:

org.json.JSONException: No value for {"0": {"pk": 41, "fields": {"heading": "Empty Lecture Slot", "notification": "There is a free lecture available right now for TE B on 2018-05-02 8:00-9:00", "date": "2018-04-25", "priority": 1, "has_read": false, "action": "/dashboard/set_substitute/91959"}, "model": "Dashboard.specificnotification"}}

如何在Android中解析此对象。

我不确定,但是json数组不像这样启动?:

[ { } ]

似乎不需要" 0"。它将自动订购

编辑:如果您的JSON有效,也可以在线检查。只是Google JSON格式。

最新更新