public class JSONFunctions extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ILLEGAL_CHAR |
static String |
ILLEGAL_ESCAPE_SEQUENCE |
static String |
ILLEGAL_UNICODE_SEQUENCE |
static String |
UNTERMINATED_STRING |
| Constructor and Description |
|---|
JSONFunctions() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendChar(Appendable a,
char ch,
boolean includeNonASCII)
Append a single character to an
Appendable applying JSON escaping rules. |
static void |
appendString(Appendable a,
CharSequence cs,
boolean includeNonASCII)
Append a
CharSequence to an Appendable in JSON quoted string form (applying JSON escaping rules). |
static String |
displayString(String str,
int maxChars)
Create a display form of a string, usually for error reporting.
|
static String |
escapeString(CharSequence cs,
boolean includeNonASCII)
Convert a
CharSequence to a String in JSON quoted string form (applying JSON escaping rules). |
static String |
escapeStringUnquoted(CharSequence cs)
Convert a
CharSequence to a String, applying JSON escaping rules with without enclosing quotes. |
static String |
escapeStringUnquoted(CharSequence cs,
boolean includeNonASCII)
Convert a
CharSequence to a String, applying JSON escaping rules with without enclosing quotes. |
static boolean |
isSpaceCharacter(char ch)
Test whether a given character is a space, according to the JSON specification.
|
static void |
outputChar(char ch,
boolean includeNonASCII,
IntConsumer consumer)
Output a single character using an
IntConsumer applying JSON escaping rules. |
static void |
outputString(CharSequence cs,
boolean includeNonASCII,
IntConsumer consumer)
Output a
CharSequence using an IntConsumer in JSON quoted string form (applying JSON escaping
rules). |
static String |
parseString(net.pwall.text.TextMatcher tm)
Parse a JSON string from the current position of a
TextMatcher (which must be positioned after the
opening double quote). |
public static final String UNTERMINATED_STRING
public static final String ILLEGAL_CHAR
public static final String ILLEGAL_UNICODE_SEQUENCE
public static final String ILLEGAL_ESCAPE_SEQUENCE
public static void appendString(Appendable a, CharSequence cs, boolean includeNonASCII) throws IOException
CharSequence to an Appendable in JSON quoted string form (applying JSON escaping rules).
The characters above the ASCII range (0x20 to 0x7E) are output as Unicode escape sequences unless
the includeNonASCII flag is set to true.a - the Appendablecs - the CharSequenceincludeNonASCII - if true, output the characters above the ASCII range without escapingIOException - if thrown by the Appendablepublic static void outputString(CharSequence cs, boolean includeNonASCII, IntConsumer consumer)
CharSequence using an IntConsumer in JSON quoted string form (applying JSON escaping
rules). The characters above the ASCII range (0x20 to 0x7E) are output as Unicode escape
sequences unless the includeNonASCII flag is set to true.cs - the CharSequenceincludeNonASCII - if true, output the characters above the ASCII range without escapingconsumer - the IntConsumerpublic static String escapeString(CharSequence cs, boolean includeNonASCII)
CharSequence to a String in JSON quoted string form (applying JSON escaping rules).
The characters above the ASCII range (0x20 to 0x7E) are output as Unicode escape sequences unless
the includeNonASCII flag is set to true.cs - the CharSequenceincludeNonASCII - if true, output the characters above the ASCII range without escapingpublic static String escapeStringUnquoted(CharSequence cs, boolean includeNonASCII)
CharSequence to a String, applying JSON escaping rules with without enclosing quotes.
The characters above the ASCII range (0x20 to 0x7E) are output as Unicode escape sequences unless
the includeNonASCII flag is set to true. If there are no characters requiring conversion, the
original string is returned unmodified.cs - the CharSequenceincludeNonASCII - if true, output the characters above the ASCII range without escapingpublic static String escapeStringUnquoted(CharSequence cs)
CharSequence to a String, applying JSON escaping rules with without enclosing quotes.
If there are no characters requiring conversion, the original string is returned unmodified.cs - the CharSequencepublic static void appendChar(Appendable a, char ch, boolean includeNonASCII) throws IOException
Appendable applying JSON escaping rules. The characters above the ASCII
range (0x20 to 0x7E) are output as Unicode escape sequences unless the includeNonASCII
flag is set to true.a - the Appendablech - the characterincludeNonASCII - if true, output the characters above the ASCII range without escapingIOException - if thrown by the Appendablepublic static void outputChar(char ch,
boolean includeNonASCII,
IntConsumer consumer)
IntConsumer applying JSON escaping rules. The characters above the
ASCII range (0x20 to 0x7E) are output as Unicode escape sequences unless the
includeNonASCII flag is set to true.ch - the characterincludeNonASCII - if true, output the characters above the ASCII range without escapingconsumer - the IntConsumerpublic static String displayString(String str, int maxChars)
... " is inserted in the middle.str - the stringmaxChars - the maximum number of characterspublic static String parseString(net.pwall.text.TextMatcher tm)
TextMatcher (which must be positioned after the
opening double quote). The index is left positioned after the closing double quote.tm - a TextMatcherIllegalArgumentException - if there are any errors in the JSONpublic static boolean isSpaceCharacter(char ch)
ch - the charactertrue if the character is a spaceCopyright © 2022. All rights reserved.