Use jackson json to serialize java objects. When the String attribute value contains backslashes, the serialization result is incorrect and contains escape characters. For example:
String str = "\\"; list.add(str); sysout(list); //The output is this backslash ["\"]
//Serialization with jackson String json = objectMapper.writeValueAsString(list); sysout(json); //The output result has two backslashes ["\ \"]
I would like to ask whether jackson has any solution? Or am I in the wrong posture, and everyone has not encountered this kind of problem?
It’s not very convenient to call a mobile phone, so we’ll settle for it.
java ‘\’ == literal ‘\’ == js ‘\’