org.codehaus.jackson.JsonParseException: Unexpected character ('�' (code 65533 / 0xfffd))

ぐ巨炮叔叔 提交于 2019-12-05 08:38:46

Short answer solution: Remove the first occurrence of the extra added BOM text with a method, such as the following, should fix this issue:

public String cleanUpJsonBOM(String json) {
      return json.trim().replaceFirst("\ufeff", "");
  }

I had a similar issue which I documented in a blog post. Hope this help!

this worked for me.

String formattedString = yourString.trim().replaceAll("\uFFFD", "");

Something is producing invalid UTF-8 sequence (or, mismatch of UTF-8 vs a single-byte encoding like ISO-8859-1), and Jackson detects this encoding problem. It has nothing to do with ACCEPT_SINGLE_VALUE_AS_ARRAY setting, as the exception comes from low-level JsonParser.

So you need to figure out why the JSON content to parse is corrupt.

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