【发布时间】:2014-02-03 10:28:37
【问题描述】:
在我的 json 示例中,我遇到了问题,无法解决。
假设我有城市课
class City {
int id;
int name;
Address address
}
有时来自服务器的地址(即 address_id,address_name ....)但在特定情况下没有地址时服务器返回 false 布尔值。
我尝试解析 jsonObject
City city = new ObjectMapper().readValue(response.toString(), City.class);
地址返回一些数据,没关系。但是当地址返回错误的布尔值时,我得到了这个错误
com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type from Boolean value。
有什么办法可以解决这个问题吗?
案例 1.
{
"isLogin": false,
"totalSum": 0,
"addressCount": 0,
"address": false,
}
案例 2.
{
"isLogin": false,
"totalSum": 378,
"addressCount": 1,
"address": {
"id": "1127",
"name": "New York",
}
【问题讨论】:
-
你能显示你的response.toString()的内容吗? ?
-
检查我编辑的答案