public class JSONValue extends Object
parse(String)
.
To encode, use toJSONString(java.lang.Object)
.Constructor and Description |
---|
JSONValue() |
Modifier and Type | Method and Description |
---|---|
static String |
escape(String s)
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
|
static void |
escape(String s,
StringBuilder sb) |
static Object |
parse(Reader in)
Parse (a.k.a., decode) JSON text into java object from the input source.
|
static Object |
parse(String s)
Parse (a.k.a., decode) JSON text into java object from the string.
|
static String |
toJSONString(boolean value)
Converts a boolean to JSON text
|
static String |
toJSONString(byte value)
Converts a byte to JSON text
|
static String |
toJSONString(char value)
Converts a char to JSON text
|
static String |
toJSONString(double value)
Converts a double to JSON text
|
static String |
toJSONString(float value)
Converts a float to JSON text
|
static String |
toJSONString(int value)
Converts an integer to JSON text
|
static String |
toJSONString(long value)
Converts a long to JSON text
|
static String |
toJSONString(Object value)
Convert (a.k.a., encode) an object to JSON text.
|
static String |
toJSONString(short value)
Converts a short to JSON text
|
static String |
toJSONString(String key,
Object value,
StringBuilder sb) |
public static Object parse(Reader in) throws IOException
in
- the input to parse.JSONObject
(also java.util.Map),
JSONArray
(also java.util.List),
java.lang.String,
java.lang.Number,
java.lang.Boolean,
null.
If in is null, null is returned.IOException
public static Object parse(String s)
public static String toJSONString(Object value)
If this object is a Map or a List, and it's also a JSONAware, JSONAware will be considered firstly.
DO NOT call this method from toJSONString() of a class that implements both JSONAware and Map or List with "this" as the parameter, use JSONObject.toJSONString(Map) or JSONArray.toJSONString(List) instead.
value
- public static String toJSONString(int value)
patched by tomyeh
public static String toJSONString(long value)
patched by tomyeh
public static String toJSONString(short value)
patched by tomyeh
public static String toJSONString(double value)
patched by tomyeh
public static String toJSONString(float value)
patched by tomyeh
public static String toJSONString(byte value)
patched by tomyeh
public static String toJSONString(boolean value)
patched by tomyeh
public static String toJSONString(char value)
patched by tomyeh
public static String escape(String s)
s
- public static String toJSONString(String key, Object value, StringBuilder sb)
public static void escape(String s, StringBuilder sb)
s
- - Must not be null.sb
- Copyright © 2020. All rights reserved.