I'm developing an app for Android, and REST Server returns the following JSON answer when I submit a GET
:
{
"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 is valid, but when I'm trying to read the contents, it returns null
. I think that it is because the object Weight has bad formation.
Should the JSON from server be changed? to something like:
{
"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
}
Most likely you are trying to read a response into some List<Object>
whereas a Server response looks like a Map<String, Object>
. Try to change your code taking it into account
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.