- java.lang.Object
-
- com.pervasive.datarush.json.JSON
-
public class JSON extends Object
The primary class that should be used for performing any JSON serialization/deserialization. This class is built on top of Jackson'sObjectMapper
and thus honors standard Jackson annotations to control serialization/deserialization. In addition, this class searches for types registered viaTypeResolutionProvider
.
-
-
Constructor Summary
Constructors Constructor Description JSON()
Create a new JSON instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
format(Object obj)
Formats the object as JSON<T> T
parse(Reader src, Class<T> asClass)
Parses the given reader as a JSON object of the given type<T> T
parse(String json, Class<T> asClass)
Parses the given string as a JSON object of the given typeString
prettyPrint(Object obj)
Pretty-prints the object as JSONvoid
relaxStandard()
Relax the JSON standard while parsing.
-
-
-
Method Detail
-
relaxStandard
public void relaxStandard()
Relax the JSON standard while parsing. Allow unquoted field names and single quotes around values.
-
parse
public <T> T parse(Reader src, Class<T> asClass)
Parses the given reader as a JSON object of the given type- Type Parameters:
T
- the type to parse as- Parameters:
src
- the readerasClass
- the type to parse as- Returns:
- an object of the requested type
-
parse
public <T> T parse(String json, Class<T> asClass)
Parses the given string as a JSON object of the given type- Type Parameters:
T
- the type to parse as- Parameters:
json
- the stringasClass
- the type to parse as- Returns:
- an object of the requested type
-
format
public String format(Object obj)
Formats the object as JSON- Parameters:
obj
- the object to format- Returns:
- the object, formatted as JSON
-
-