public class JSONComponents
extends java.lang.Object
| Constructor and Description |
|---|
JSONComponents() |
| Modifier and Type | Method and Description |
|---|---|
static void |
escapeChars(java.lang.String string,
java.lang.Appendable buf)
Append a string with backslash sequences in all the right places.
|
static java.lang.String |
numberToString(java.lang.Number number)
Produce a string from a Number.
|
static java.lang.String |
quote(java.lang.String string)
Produce a string in double quotes with backslash sequences in all the right places.
|
static void |
quote(java.lang.String string,
java.lang.Appendable buf) |
static java.lang.Object |
stringToValue(java.lang.String string)
Try to convert a string into a number, boolean, or null.
|
static void |
testValidity(java.lang.Object o)
Throw an exception if the object is a NaN or infinite number.
|
static java.lang.String |
valueToString(java.lang.Object value)
Make a JSON text of an Object value.
|
static void |
writeValue(java.lang.Object value,
java.lang.Appendable buf) |
public static void escapeChars(java.lang.String string,
java.lang.Appendable buf)
throws java.io.IOException
string - A Stringbuf - The Appendable that the escaped String will be appended onto.java.io.IOException - if it is not possible to write to the bufpublic static java.lang.Object stringToValue(java.lang.String string)
string - A String.public static java.lang.String quote(java.lang.String string)
string - A Stringpublic static void quote(java.lang.String string,
java.lang.Appendable buf)
throws java.io.IOException
java.io.IOExceptionpublic static void testValidity(java.lang.Object o)
throws JSONRuntimeException
o - The object to test.JSONRuntimeException - If o is a non-finite number.public static java.lang.String numberToString(java.lang.Number number)
throws JSONRuntimeException
number - A NumberJSONRuntimeException - If n is a non-finite number.public static java.lang.String valueToString(java.lang.Object value)
Warning: This method assumes that the data structure is acyclical.
value - The value to be serialized.{ (left brace) and ending with }
(right brace).JSONRuntimeException - If the value is or contains an invalid number.public static void writeValue(java.lang.Object value,
java.lang.Appendable buf)
throws java.io.IOException
java.io.IOException