Class JsonpCharacterEscapes

java.lang.Object
com.fasterxml.jackson.core.io.CharacterEscapes
com.fasterxml.jackson.core.JsonpCharacterEscapes
All Implemented Interfaces:
Serializable

public class JsonpCharacterEscapes extends CharacterEscapes
Convenience CharacterEscapes implementation that escapes Unicode characters `0x2028` and `0x2029` (in addition to characters escaped otherwise), which are apparently considered linefeeds as per newer Javascript specifications, and consequently problematic when using JSONP (see https://en.wikipedia.org/wiki/JSONP).
Since:
2.8
See Also:
  • Constructor Details

    • JsonpCharacterEscapes

      public JsonpCharacterEscapes()
  • Method Details

    • instance

      public static JsonpCharacterEscapes instance()
    • getEscapeSequence

      public SerializableString getEscapeSequence(int ch)
      Description copied from class: CharacterEscapes
      Method generators can call to get lookup table for determining exact escape sequence to use for given character. It can be called for any character, but typically is called for either for ASCII characters for which custom escape sequence is needed; or for any non-ASCII character.
      Specified by:
      getEscapeSequence in class CharacterEscapes
      Parameters:
      ch - Character to look escape sequence for
      Returns:
      Escape sequence to use for the character, if any; null if not
    • getEscapeCodesForAscii

      public int[] getEscapeCodesForAscii()
      Description copied from class: CharacterEscapes
      Method generators can call to get lookup table for determining escape handling for first 128 characters of Unicode (ASCII characters. Caller is not to modify contents of this array, since this is expected to be a shared copy.
      Specified by:
      getEscapeCodesForAscii in class CharacterEscapes
      Returns:
      Array with size of at least 128, where first 128 entries have either one of ESCAPE_xxx constants, or non-zero positive integer (meaning of which is data format specific; for JSON it means that combination of backslash and character with that value is to be used) to indicate that specific escape sequence is to be used.