Class JSONValue
java.lang.Object
com.pnfsoftware.jeb.util.encoding.json.JSONValue
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringEscape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).static ObjectDeprecated.static ObjectDeprecated.this method may throw anErrorinstead of returningnull; please useparseWithException(String)insteadstatic ObjectParse JSON text into java object from the input source.static Objectstatic StringtoJSONString(Object value) Convert an object to JSON text.static voidwriteJSONString(Object value, Writer out) Encode an object into JSON text and write it to out.
-
Constructor Details
-
JSONValue
public JSONValue()
-
-
Method Details
-
parse
Deprecated.this method may throw anErrorinstead of returningnull; please useparseWithException(Reader)insteadParse JSON text into java object from the input source. Please use parseWithException() if you don't want to ignore the exception.- Parameters:
in-- Returns:
- Instance of the following: org.json.simple.JSONObject, org.json.simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
- See Also:
-
JSONParser.parse(Reader)parseWithException(Reader)
-
parse
Deprecated.this method may throw anErrorinstead of returningnull; please useparseWithException(String)insteadParse JSON text into java object from the given string. Please use parseWithException() if you don't want to ignore the exception.- Parameters:
s-- Returns:
- Instance of the following: org.json.simple.JSONObject, org.json.simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
- See Also:
-
JSONParser.parse(Reader)parseWithException(Reader)
-
parseWithException
public static Object parseWithException(Reader in) throws IOException, org.json.simple.parser.ParseException Parse JSON text into java object from the input source.- Parameters:
in-- Returns:
- Instance of the following: org.json.simple.JSONObject, org.json.simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
- Throws:
IOExceptionorg.json.simple.parser.ParseException- See Also:
-
JSONParser
-
parseWithException
- Throws:
org.json.simple.parser.ParseException
-
writeJSONString
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.
DO NOT call this method from writeJSONString(Writer) of a class that implements both JSONStreamAware and (Map or List) with "this" as the first parameter, use JSONObject.writeJSONString(Map, Writer) or JSONArray.writeJSONString(List, Writer) instead.
- Parameters:
value-writer-- Throws:
IOException- See Also:
-
JSONObject.writeJSONString(Map, Writer)JSONArray.writeJSONString(List, Writer)
-
toJSONString
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.
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.
- Parameters:
value-- 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
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).- Parameters:
s-- Returns:
-
Errorinstead of returningnull; please useparseWithException(Reader)instead