public void setJavaScriptEscapeChars ( final int [ ] escapeCharacters ) { final CharacterEscapes ce = new CharacterEscapes ( ) { private static final long serialVersionUID = 1L ; @ Override public int [ ] getEscapeCodesForAscii ( ) { if ( escapeCharacters == null ) { return CharacterEscapes . standardAsciiEscapesForJSON ( ) ; } return escapeCharacters ; } @ Override public SerializableString getEscapeSequence ( final int ch ) { final String jsEscaped = escapeChar ( ( char ) ch ) ; return new SerializedString ( jsEscaped ) ; } } ; jsonGenerator . setCharacterEscapes ( ce ) ; }
By default JSON output does only have escaping where it is strictly necessary . This is recommended in the most cases . Nevertheless it can be sometimes useful to have some more escaping .