首页 前端知识 JSON parse error: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backsla

JSON parse error: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backsla

2024-05-10 08:05:44 前端知识 前端哥 556 637 我要收藏

JSON parse error: Illegal unquoted character ((CTRL-CHAR, code 10)):
has to be escaped using backslash to be included in string value;
nested exception is
com.fasterxml.jackson.databind.JsonMappingException: Illegal unquoted
character ((CTRL-CHAR, code 10)): has to be escaped using backslash to
be included in string value\n at [Source: (PushbackInputStream);

百度翻译如下

JSON解析错误:非法的无引号字符((CTRL-CHAR,代码10):必须使用反斜杠进行转义才能包含在字符串值中;嵌套异常为com.fasterxml.jackson.databind.JsonMappingException:非法的无引号字符((CTRL-CHAR,代码10):必须使用反斜杠进行转义,才能包含在[Source:(PushbackInputStream);

出现原因:Json 字符中有有些字段比如空格、反斜杠、换行符等一些特殊字符,但是 Json 框架没有对这些字符进行处理,就会导致出现错误。

SpringBoot项目解决方法

1、首先加入 fastjson 依赖
复制
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
复制
2、在配置文件中加入
复制
spring:
jackson:
parser:
allow-unquoted-control-chars: true
复制
3、重启项目、测试
复制
转载请注明出处或者链接地址:https://www.qianduange.cn//article/7914.html
标签
maven
评论
还可以输入200
共0条数据,当前/页
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!