本文主要是介绍JsonParseException : Illegal unquoted character ((CTRL-CHAR, code 10),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
报错JsonParseException : Illegal unquoted character ((CTRL-CHAR, code 10)的解决方法
一、报错原因
我调用第三方接口获取返回的JSON数据时报上面的错误。原因是对方接口响应的JSON中包含特殊字符,比如\n。当我们对这个JSON进行解析时就会报错JsonParseException : Illegal unquoted character ((CTRL-CHAR, code 10)。
二、解决方法
在解析JSON前设置下面配置
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
OtherMessage otherMessage = objectMapper.readValue(text, OtherMessage.class);
这篇关于JsonParseException : Illegal unquoted character ((CTRL-CHAR, code 10)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!