Package org.noggit
Class JSONUtil
- java.lang.Object
-
- org.noggit.JSONUtil
-
public class JSONUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static char
ARRAY_END
static char
ARRAY_START
static char[]
FALSE_CHARS
static char[]
HEX_CHARS
static char
NAME_SEPARATOR
static char[]
NULL_CHARS
static char
OBJECT_END
static char
OBJECT_START
static char[]
TRUE_CHARS
static char
VALUE_SEPARATOR
-
Constructor Summary
Constructors Constructor Description JSONUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
toJSON(Object o)
static String
toJSON(Object o, int indentSize)
static void
unicodeEscape(int ch, CharArr out)
static void
writeBoolean(boolean val, CharArr out)
static void
writeChar(char ch, CharArr out)
static void
writeNull(CharArr out)
static void
writeNumber(double number, CharArr out)
static void
writeNumber(float number, CharArr out)
static void
writeNumber(int number, CharArr out)
static void
writeNumber(long number, CharArr out)
static void
writeString(char[] val, int start, int end, CharArr out)
static void
writeString(CharSequence val, int start, int end, CharArr out)
static void
writeString(String val, int start, int end, CharArr out)
static void
writeString(CharArr val, CharArr out)
static void
writeStringPart(char[] val, int start, int end, CharArr out)
static void
writeStringPart(CharSequence chars, int start, int end, CharArr out)
static void
writeStringPart(String chars, int start, int end, CharArr out)
-
-
-
Field Detail
-
TRUE_CHARS
public static final char[] TRUE_CHARS
-
FALSE_CHARS
public static final char[] FALSE_CHARS
-
NULL_CHARS
public static final char[] NULL_CHARS
-
HEX_CHARS
public static final char[] HEX_CHARS
-
VALUE_SEPARATOR
public static final char VALUE_SEPARATOR
- See Also:
- Constant Field Values
-
NAME_SEPARATOR
public static final char NAME_SEPARATOR
- See Also:
- Constant Field Values
-
OBJECT_START
public static final char OBJECT_START
- See Also:
- Constant Field Values
-
OBJECT_END
public static final char OBJECT_END
- See Also:
- Constant Field Values
-
ARRAY_START
public static final char ARRAY_START
- See Also:
- Constant Field Values
-
ARRAY_END
public static final char ARRAY_END
- See Also:
- Constant Field Values
-
-
Method Detail
-
toJSON
public static String toJSON(Object o, int indentSize)
- Parameters:
o
- The object to convert to JSONindentSize
- The number of space characters to use as an indent (default 2). 0=newlines but no spaces, -1=no indent at all.
-
writeNumber
public static void writeNumber(int number, CharArr out)
-
writeNumber
public static void writeNumber(long number, CharArr out)
-
writeNumber
public static void writeNumber(float number, CharArr out)
-
writeNumber
public static void writeNumber(double number, CharArr out)
-
writeString
public static void writeString(char[] val, int start, int end, CharArr out)
-
writeString
public static void writeString(CharSequence val, int start, int end, CharArr out)
-
writeStringPart
public static void writeStringPart(char[] val, int start, int end, CharArr out)
-
writeChar
public static void writeChar(char ch, CharArr out)
-
writeStringPart
public static void writeStringPart(CharSequence chars, int start, int end, CharArr out)
-
unicodeEscape
public static void unicodeEscape(int ch, CharArr out)
-
writeNull
public static void writeNull(CharArr out)
-
writeBoolean
public static void writeBoolean(boolean val, CharArr out)
-
-