Package org.zkoss.zats.common.json
Class JSONValue
- java.lang.Object
-
- org.zkoss.zats.common.json.JSONValue
-
public class JSONValue extends Object
- Since:
- 1.1.0
- Author:
- FangYidong
, Uriel Chemouni
-
-
Constructor Summary
Constructors Constructor Description JSONValue()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringescape(String s)Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).static voidescape(String s, Appendable ap)static Objectparse(Reader in)Parse JSON text into java object from the input source.static Objectparse(String s)static ObjectparseWithException(Reader in)Parse JSON text into java object from the input source.static ObjectparseWithException(String s)static StringtoJSONString(Object value)Convert an object to JSON text.static voidwriteJSONString(Object value, Appendable out)Encode an object into JSON text and write it to out.
-
-
-
Method Detail
-
parse
public static Object parse(Reader in)
Parse JSON text into java object from the input source. Please use parseWithException() if you don't want to ignore the exception.- Returns:
- Instance of the following: JSONObject, JSONArray, String, java.lang.Number, java.lang.Boolean, null
- See Also:
JSONParserStream.parse(Reader),parseWithException(Reader)
-
parseWithException
public static Object parseWithException(Reader in) throws IOException, ParseException
Parse JSON text into java object from the input source.- Returns:
- Instance of the following: JSONObject, JSONArray, String, java.lang.Number, java.lang.Boolean, null
- Throws:
IOExceptionParseException- See Also:
parser.JSONParser
-
parseWithException
public static Object parseWithException(String s) throws ParseException
- Throws:
ParseException
-
writeJSONString
public static void writeJSONString(Object value, Appendable out) throws IOException
Encode an object into JSON text and write it to out.If this object is a Map or a List, and it's also a JSONStreamAware or a JSONAware, JSONStreamAware or JSONAware will be considered firstly.
-
toJSONString
public static String toJSONString(Object value)
Convert an object to JSON text.If this object is a Map or a List, and it's also a JSONAware, JSONAware will be considered firstly.
- Returns:
- JSON text, or "null" if value is null or it's an NaN or an INF number.
- See Also:
JSONObject.toJSONString(Map),JSONArray.toJSONString(List)
-
escape
public static String escape(String s)
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
-
escape
public static void escape(String s, Appendable ap)
-
-