JsonparseException Illegal unquoted character ((CTRL-CHAR, code 10)

*爱你&永不变心* 提交于 2019-11-27 19:34:09

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"}
hoang

Using

mapper.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);

See javadoc:

 /**
   * Feature that determines whether parser will allow
   * JSON Strings to contain unquoted control characters
   * (ASCII characters with value less than 32, including
   * tab and line feed characters) or not.
   * If feature is set false, an exception is thrown if such a
   * character is encountered.
   *<p>
   * Since JSON specification requires quoting for all control characters,
   * this is a non-standard feature, and as such disabled by default.
   */

I'd recommend you to use a text editor such as Vim to find if there are any (invisible) special or escape characters causing this issue.

Or if you are using windows, it's even simple... just copy-paste the code in windows notepad, and it will most likely show any invisible unwanted escape characters or line breaks etc. fix them and you're done!

On Salesforce platform this error is caused by /, the solution is to escape these as //.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!