Jackson Unmarshalling fails to ALLOW_UNQUOTED_CONTROL_CHARS in 2.17.0.redhat-630371 version

Solution Verified - Updated -

Issue

  • We receive new line control chars from calling applications and use Jackson Mapper classes to handle it. It was working fine in Fuse 6.3.0 R5 BOM. However with 2.17.0.redhat-630371 version, it throws the com.fasterxml.jackson.core.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value exception and fails to unmarshall.

Code snippets

public static Map<String, Object> unmarshalJson(final String from)
            throws IOException {
        JsonFactory factory = new JsonFactory();
        ObjectMapper mapper = new ObjectMapper(factory);
        mapper.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
        TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
        };
        return mapper.readValue(from, typeRef);
    }

Map<String, Object> jsonRequestMap = JacksonMapper.unmarshalJson((String) exchange.getIn().getBody());

Input JSON data

{"noteDescription":"Postman's automated testing.\n\nNext line and pound symbol £30.00 testing"}

Environment

  • Red Hat Fuse
    • 6.3.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In