[英]com.fasterxml.jackson.core.JsonParseException: Unexpected character(code 160) while reading the json file
I am reading the below json content from a file and converting into a map but i am getting the below exception. 我正在从文件中读取以下json内容并转换为地图,但我得到以下异常。 Kindly let me know if anybody has come across such issue.
如果有人遇到过这样的问题,请告诉我。 I validated my json content and looks valid.
我验证了我的json内容并且看起来有效。 Not sure why this error.
不知道为什么这个错误。
Json Content: Json内容:
{
"Results":[{
"TotalPositiveFeedbackCount": 0
},{
"TotalPositiveFeedbackCount": 1
} ]
}
Code: 码:
Map<String, Object> domainMap = new HashMap<String, Object>();
try {
responseJson = getFile("reviewresponse.json");
//responseJson = new String(Files.readAllBytes(Paths.get("reviewresponse.json")), StandardCharsets.UTF_8);
ObjectMapper jsonObjectMapper = new ObjectMapper();
jsonObjectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
domainMap = jsonObjectMapper.readValue(responseJson,
new TypeReference<Map<String, Object>>() {});
}
Exception Details: 例外细节:
com.fasterxml.jackson.core.JsonParseException: Unexpected character (' ' (code 160)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name
at [Source: {
"Results":[{
"TotalPositiveFeedbackCount": 0
},{
"TotalPositiveFeedbackCount": 1
} ]
}
; line: 2, column: 15]
Your JSON content contains non-breaking spaces (character code 160, commonly known as
) likely from copying and pasting JSON (usually from a webpage) that used
您的JSON内容包含可能通过复制和粘贴使用了
JSON(通常来自网页)的不间断空格(字符代码160,通常称为
) to indent the JSON. 缩进JSON。
You can fix it with 你可以修复它
responseJson = responseJson.replace('\u00A0',' ');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.