> 文档中心 > 解决JSON parse error: Cannot deserialize instance of `java.lang.Integer` out of VALUE_TRUE token; nest

解决JSON parse error: Cannot deserialize instance of `java.lang.Integer` out of VALUE_TRUE token; nest

前端联调的时候,不小心出错了。

错误信息如下

JSON parse error: Cannot deserialize instance of `java.lang.Integer` out of VALUE_TRUE token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.lang.Integer` out of VALUE_TRUE token\n at [Source: (PushbackInputStream); line: 1, column: 1373] (through reference chain:

看了下问题,主要是字段命名惹的祸。

 @ApiModelProperty(value = "是否显示") private Integer isShow;

MVC在帮你转换为json格式的时候,默认会把is开头的属性,给你转成布尔型。

真不知道这是好事情还是坏事情。

知道问题了,就好办了,直接把类型改了,或者把字段名改了就可以了。

总结下

在数据库命名的时候,最好不要使用is开头来设置字段,有些第三方喜欢帮你做一些你想不到的便利的事情。例如上面的情况。