JsonparseException非法无引号字符((CTRL-CHAR,代码10) [英] JsonparseException Illegal unquoted character ((CTRL-CHAR, code 10)
问题描述
我尝试使用 org.apache.httpcomponents
来使用rest api,它会将json格式的数据发布到api。
I'm trying to use org.apache.httpcomponents
to consume a rest api ,which will post json format data to api.
而我得到异常
原因:com.fasterxml.jackson.core.JsonParseException:Illegal
无引号字符((CTRL-CHAR,代码10)):必须使用
反斜杠转义以包含在字符串中。
Caused by: com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string.
原因是 ctrl-char
包含在json字符串中。
The reason is ctrl-char
is included in the json string.
这个或者一些解决方案?
Is there any way to replace this .or some solution else?
感谢!
推荐答案
(或其他控制字符)。
This can happen if you have a newline (or other control character) in a JSON string literal.
{"foo": "bar
baz"}
如果您是生成数据的那个,请使用转义替换实际的换行 \\\\
。
If you are the one producing the data, replace actual newlines with escaped ones "\\n"
when creating your string literals.
{"foo": "bar\nbaz"}
这篇关于JsonparseException非法无引号字符((CTRL-CHAR,代码10)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!