【发布时间】:2018-10-06 11:40:27
【问题描述】:
这是我从服务器得到的 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);
这是我在 catch 块中遇到的错误:
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 中解析这个对象。
【问题讨论】:
-
我认为你必须在Java中实现一个与JSON对象匹配的POJO类
标签: java android python django python-3.x