贝儿猪
2021-10-06 11:34
采纳率: 0%
浏览 23

无法将RestTemplate 的结果转换城list

sample JSON

"posts": [{
"id": 1,
"author": "Rylee Paul",
"authorId": 9,
"likes": 960,
"popularity": 0.13,
"reads": 50361,
"tags": [ "tech", "health" ]
},

一个实体类


  private int id;
    private String author;
    private int authorId;
    private int likes;
    private double popularity;
    private long reads;

    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    private List<String> tags;

service


ResponseEntity<Post []> responseEntity =restTemplate.getForEntity(url,Post[].class,tagName);
        Post [] posts=responseEntity.getBody();

getForEntity报错了,


com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `[Lcom.example.demo.data.Post;` from Object value (token `JsonToken.START_OBJECT`)

有没有哪位知道这是咋回事?

1条回答 默认 最新

相关推荐 更多相似问题