DevInfo: How to make Jackson to avoid excaping backslash?
private static final ObjectMapper mapper = new ObjectMapper(new ObjectMapper().getFactory().setCharacterEscapes(new CharacterEscapes() {@Override
public int[] getEscapeCodesForAscii() {
// add standard set of escaping characters
int[] esc = CharacterEscapes.standardAsciiEscapesForJSON();
// don't escape backslash (not to corrupt windows path)
esc['\\'] = CharacterEscapes.ESCAPE_NONE;
return esc;
}
@Override
public SerializableString getEscapeSequence(int i) {
// no further escaping (beyond ASCII chars) needed
return null;
}
})).enable(INDENT_OUTPUT);
Read full article from DevInfo: How to make Jackson to avoid excaping backslash?
No comments:
Post a Comment