我正在开发适用于Android的应用,当我提交GET
时,REST Server返回以下JSON答案:
{
"result": "ok",
"code": 1000,
"code_desc": "Command Done Successfully",
"method": "get",
"call_id": null,
"timestamp": 1539100644,
"weight": {
"1": {
"id": 1,
"customer_id": 1,
"date": "2018-10-04 12:02:00",
"value": 100,
"observations": ""
},
"2": {
"id": 2,
"customer_id": 1,
"date": "2018-10-04 12:02:00",
"value": 100,
"observations": ""
}
},
"order": "date",
"sorder": "ASC",
"total": 2
}
JSON是有效的,但是当我尝试读取内容时,它返回null
。
我认为这是因为对象“权重”的形成不良。
是否应更改服务器中的JSON?像这样:
{
"result": "ok",
"code": 1000,
"code_desc": "Command Done Successfully",
"method": "get",
"call_id": null,
"timestamp": 1539100644,
"weight": [{
"id": 1,
"customer_id": 1,
"date": "2018-10-04 12:02:00",
"value": 100,
"observations": ""
},
{
"id": 2,
"customer_id": 1,
"date": "2018-10-04 12:02:00",
"value": 100,
"observations": ""
}
],
"order": "date",
"sorder": "ASC",
"total": 2
}
答案 0 :(得分:-1)
您很有可能尝试将响应读入某些List<Object>
,而服务器响应看起来像是Map<String, Object>
。考虑到它,尝试更改您的代码