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

Posted 沛沛老爹

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决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开头来设置字段,有些第三方喜欢帮你做一些你想不到的便利的事情。例如上面的情况。

以上是关于解决JSON parse error: Cannot deserialize instance of `java.lang.Integer` out of VALUE_TRUE token; nest的主要内容,如果未能解决你的问题,请参考以下文章

JSON parse error: Invalid UTF-8 解决办法系列

Eclipse 解决JSON parse error: Invalid UTF-8 总结 完善

解决npm安装模块时 npm err! registry error parsing json

“JSON parse error: Unexpected character (‘1‘ (code 49))的解决方式

Feign踩坑记录:JSON parse error

JSON parse error: Invalid UTF-8 start byte 0xa0 问题记录及解决方法