Package org.drip.service.representation
Class JSONValue
java.lang.Object
org.drip.service.representation.JSONValue
public class JSONValue
extends java.lang.Object
JSONValue is an Adaptation of the JSONValue Class from the RFC4627 compliant JSON Simple
(https://code.google.com/p/json-simple/). It provides the following Functionality:
- Implement "escape" on the String and copy it into the Buffer
- Parse JSON text into java object from the input source. Please use parseWithException() if you don't want to ignore the exception
- Parse the Input String into an Object
- Parse JSON text into java object from the input source
- Parse JSON text into java object from the input string
- Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F)
- Encode an object into JSON text and write it to writer
- Convert an object to JSON text
Module | Computational Core Module |
Library | Computation Support |
Project | Environment, Product/Definition Containers, and Scenario/State Manipulation APIs |
Package | RFC4627 Compliant JSON Message Object |
- Author:
- Fang Yidong, Lakshmi Krishnamurthy
-
Constructor Summary
Constructors Constructor Description JSONValue()
-
Method Summary
Modifier and Type Method Description static java.lang.String
escape(java.lang.String s)
Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).static java.lang.Object
parse(java.io.StringReader inStringReader)
Parse JSON text into java object from the input source.static java.lang.Object
parse(java.lang.String s)
Parse the Input String into an Objectstatic java.lang.Object
parseWithException(java.io.Reader inputReader)
Parse JSON text into java object from the input source.static java.lang.Object
parseWithException(java.lang.String s)
Parse JSON text into java object from the input string.static java.lang.String
toJSONString(java.lang.Object value)
Convert an object to JSON text.static void
writeJSONString(java.lang.Object value, java.io.Writer writer)
Encode an object into JSON text and write it to writer.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
JSONValue
public JSONValue()
-
-
Method Details
-
parse
public static java.lang.Object parse(java.io.StringReader inStringReader)Parse JSON text into java object from the input source. Please use parseWithException() if you don't want to ignore the exception.- Parameters:
inStringReader
- Input String Reader- Returns:
- Instance of the following: org.drip.json.simple.JSONObject, org.drip.json.simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
- See Also:
LexicalProcessor.parse(Reader)
,parseWithException(Reader)
-
parse
public static java.lang.Object parse(java.lang.String s)Parse the Input String into an Object- Parameters:
s
- Input String- Returns:
- The Parsed Object
-
parseWithException
public static java.lang.Object parseWithException(java.io.Reader inputReader) throws java.io.IOException, ParseExceptionParse JSON text into java object from the input source.- Parameters:
inputReader
- Input Reader- Returns:
- Instance of the following: org.json.simple.JSONObject, org.json.simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
- Throws:
java.io.IOException
- Thrown if the Inputs are InvalidParseException
- Thrown if the Inputs are Invalid- See Also:
LexicalProcessor
-
parseWithException
Parse JSON text into java object from the input string.- Parameters:
s
- Input String- Returns:
- Instance of the following: org.json.simple.JSONObject, org.json.simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
- Throws:
ParseException
- Thrown if the Inputs are Invalid- See Also:
LexicalProcessor
-
escape
public static java.lang.String escape(java.lang.String s)Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).- Parameters:
s
- Pre-escape String- Returns:
- The Escape String
-
writeJSONString
public static void writeJSONString(java.lang.Object value, java.io.Writer writer) throws java.io.IOExceptionEncode an object into JSON text and write it to writer.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
- The JSON Objectwriter
- The JSON Writer- Throws:
java.io.IOException
- Thrown if the Inputs are Invalid- See Also:
JSONObject.writeJSONString(Map, Writer)
,JSONArray.writeJSONString(List, Writer)
-
toJSONString
public static java.lang.String toJSONString(java.lang.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.
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
- The JSON Object- 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)
-