com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of 错误

1. 错误信息:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList out of START_OBJECT token

踩坑:
SpringBoot 反序列化报错
想把json数据直接转成对象,实体类其中有个属性是java.util.List;的,多写了一个持续输出报错,然后就凉凉月色为你思念成河!!!

原文:

public class Data {
    private String shidu;
    private Integer pm25;
    private Integer pm10;
    private String quality;
    private String wendu;
    private String ganmao;
    private List forecast;
	private List yesterday;
}

修改后的:

public class Data {
    private String shidu;
    private Integer pm25;
    private Integer pm10;
    private String quality;
    private String wendu;
    private String ganmao;
    private List forecast;
    private Yesterday yesterday;
}

这样就好了,
JSON 转换工具:检查你的JSON数据是否标准
推荐网址:http://www.bejson.com/

2. 错误信息二
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct (no Creators)
这个错误是由于你没有在实体类里面没有写无参的构造函数

还好今天只遇到了这两个错误,幸哉!

你可能感兴趣的:(Spring,Boot)