Package com.fasterxml.jackson.core
Class JsonpCharacterEscapes
- java.lang.Object
-
- com.fasterxml.jackson.core.io.CharacterEscapes
-
- com.fasterxml.jackson.core.JsonpCharacterEscapes
-
- All Implemented Interfaces:
java.io.Serializable
public class JsonpCharacterEscapes extends CharacterEscapes
ConvenienceCharacterEscapes
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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.fasterxml.jackson.core.io.CharacterEscapes
ESCAPE_CUSTOM, ESCAPE_NONE, ESCAPE_STANDARD
-
-
Constructor Summary
Constructors Constructor Description JsonpCharacterEscapes()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]
getEscapeCodesForAscii()
Method generators can call to get lookup table for determining escape handling for first 128 characters of Unicode (ASCII characters.SerializableString
getEscapeSequence(int ch)
Method generators can call to get lookup table for determining exact escape sequence to use for given character.static JsonpCharacterEscapes
instance()
-
Methods inherited from class com.fasterxml.jackson.core.io.CharacterEscapes
standardAsciiEscapesForJSON
-
-
-
-
Method Detail
-
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 classCharacterEscapes
- 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 classCharacterEscapes
- 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.
-
-