【发布时间】:2019-11-23 08:42:43
【问题描述】:
我想解析 json 值,但是有些值没有键。
喜欢这个
"geometry": {
"type": "LineString",
"coordinates": [
[
127.08373748622218,
37.529508099979225
],
[
127.08355138558433,
37.529735847943925
]
]
}
几何.class
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@ToString
public class Geometry {
private String type;
private Coordinate coordinates;
}
坐标类
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@ToString
public class Coordinate {
private List<Double[]> xy;
}
然后我看到了这个错误
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `kr.seoulmaas.ieye.service.dto.path.walk.Coordinate` out of START_ARRAY token
at [Source: (PushbackInputStream); line: 1, column: 133] (through reference chain: kr.seoulmaas.ieye.service.dto.path.WalkPathResDto["features"]->java.util.ArrayList[0]->kr.seoulmaas.ieye.service.dto.path.walk.Feature["geometry"]->kr.seoulmaas.ieye.service.dto.path.walk.Geometry["coordinates"])
【问题讨论】:
-
发布一个 complete 最小示例,使用硬编码的 JSON 输入,尝试反序列化此 JSON 输入。
-
显示
RestTemplate代码
标签: java json spring-boot resttemplate