【发布时间】:2018-01-23 00:39:18
【问题描述】:
我得到了服务器响应我的 json:
{
"clients": {
"0": {
"id": 12370691,
"fio": ""
},
"2": {
"id": 12384782,
"fio": "name2"
},
"3": {
"id": 12389624,
"fio": "Name3"
}
}
}
由于 jsons,我得到了 pojos。
第一个 Pojo 包含对象映射
@Data
public class GetClientsResponse {
@JsonProperty("clients")
Map<String, ClientResponse> clientMap;
public List<ClientResponse> getListOfValues() {
if (Objects.nonNull(this.clientMap)) {
return this.clientMap.entrySet()
.stream()
.map(entry -> entry.getValue())
.collect(Collectors.toList());
}
return Collections.emptyList();
}
}
和ClientResponse类
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ClientResponse {
@JsonProperty("id")
private int clientId;
@JsonProperty("fio")
private String fullName;
}
我得到了下一个错误:
出现意外错误(类型=错误请求,状态=400)。 JSON 解析错误:无法反序列化 java.util.LinkedHashMap 的实例 超出 START_ARRAY 令牌;嵌套异常是 com.fasterxml.jackson.databind.JsonMappingException:不能 从 START_ARRAY 中反序列化 java.util.LinkedHashMap 的实例 [来源:java.io.PushbackInputStream@2a8f551b;线:1, 列:12](通过参考链: com.lineup.flatsender.model.dto.response.avers.getclinets.GetClientsResponse["clients"]) 块引用
谁能解释一下是什么问题?因为它在 1 个月前有效,我没有任何问题。 我正在使用 import org.springframework.web.client.RestOperations;
【问题讨论】: