'Remove \n\r from HTML when converting html to string and storing that string to JSON node

I am having one html string e.g

String strHTML = "<html><body>Hello\nworld</body></html>";

When I am trying to put this String in JsonNode

JsonNode jsonNode= ObjectMapper.convertValue(strHTML ,JsonNode.class);

output is

<html>\n\r<body style = \"text-align:center;\":>\n\r\n\rHello nworld</body>\n\r\n\r</html>

And I don't want to use string.replace and also want to remove \ before "



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source