我有以下json :(我在名为locations的对象中看到一个地图) 我做了一个gson调用,将它转换为带有地图的对象。 也许我看到json错了。 我做错了什么?
{
"locations": {
"0": {
"locationNo": "10014",
"inventoryLocationNo": "10014"
},
"1": {
"locationNo": "10022",
"inventoryLocationNo": "10022"
},
"2": {
"locationNo": "10030",
"inventoryLocationNo": "10030"
},
},
"errors": {}
}
我拨打电话时收到异常:
BATOLocationIDAPIResponse responseObject = gson.fromJson(container.body, BATOLocationIDAPIResponse.class);
/**
* POJO that represents the response wrapper for a Location API call.
*
*/
public class BATOLocationIDAPIResponse {
private BATOLocationContainer locations;
private List<String> errors;
}
public List<String> getErrors() {
return errors;
}
public class BATOLocationContainer {
private Map<String, BATOAPILocation> locations;
}
}
// Location object
public class BATOAPILocation {
public String locationNo;
public String inventoryLocationNo;
}
答案 0 :(得分:0)
您有private List<String> errors;
,但您的JSON显示"errors": {}
这应该是"errors": []