Solution to the error JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10))
1. Reason for error reporting
When I call a third-party interface to obtain the returned JSON data, I get the above error. The reason is that the JSON responded by the other party's interface contains special characters, such as \n. When we parse this JSON, we will get an error JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10)).
2. Solution
Set the following configuration before parsing JSON
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
OtherMessage otherMessage = objectMapper.readValue(text, OtherMessage.class);