public class JsonBackend
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
JsonBackend.ProCharacterEscapes
A singleton class used for escaping characters while writing JSON strings.
|
private static class |
JsonBackend.ProPrettyPrinter
Singleton used for overwriting the separator between the field name and its value in a JSON string.
|
private static class |
JsonBackend.TwoSpacesIndenter
Singleton used for matching the indentation of the output JSON string with 4GL.
|
| Modifier and Type | Field and Description |
|---|---|
private com.fasterxml.jackson.core.JsonFactory |
factory
Thread-safe factory instance.
|
private static JsonBackend |
instance
The singleton instance.
|
static int |
JSON_ARRAY
Numeric value for JSON Array type.
|
static int |
JSON_BOOLEAN
Numeric value for JSON Logical type.
|
static int |
JSON_NULL
Numeric value for JSON null type.
|
static int |
JSON_NUMBER
Numeric value for JSON Number type.
|
static int |
JSON_OBJECT
Numeric value for JSON Object type.
|
static int |
JSON_STRING
Numeric value for JSON String type.
|
| Modifier | Constructor and Description |
|---|---|
private |
JsonBackend()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private static void |
checkValidConstruct(JsonConstruct con,
com.fasterxml.jackson.core.JsonParser parser)
Throw a
JsonParseException if the the argument is not a valid construct. |
static java.lang.Object |
convertLegacyValueToJson(BaseDataType value)
Converts the legacy value to a native Java value suitable for json serialization.
|
private static com.fasterxml.jackson.core.JsonEncoding |
getEncoding(java.lang.String legacyEncoding)
Converts the legacy encoding name to JsonEncoding.
|
static int |
getJsonDataType(java.lang.Object value)
|
static java.lang.String |
getJsonDataTypeName(int type)
Returns the string representation of object's corresponding JSON data type.
|
static JsonBackend |
instance()
Returns the singleton instance.
|
object<? extends JsonConstruct> |
parse(java.io.Reader source)
Deserializes the supplied input stream into a json object tree.
|
object<? extends JsonConstruct> |
parse(java.lang.String source)
Deserializes the source text into a json object tree.
|
private static object<? extends JsonConstruct> |
parseImpl(com.fasterxml.jackson.core.JsonParser parser)
Deserializes json object tree using the supplied parser as the input of json tokens.
|
private static void |
throwParserException(com.fasterxml.jackson.core.JsonParser parser)
Convenience function to throw
JsonParseException. |
java.lang.String |
write(java.io.OutputStream target,
JsonConstruct construct,
boolean prettyPrint,
java.lang.String legacyEnc)
Serializes the supplied json construct instance to the target output stream.
|
private void |
writeConstruct(com.fasterxml.jackson.core.JsonGenerator jsonGen,
JsonConstruct construct)
Implements serialization of the supplied json construct instance using the supplied json generator.
|
private void |
writeValue(com.fasterxml.jackson.core.JsonGenerator jsonGen,
java.lang.Object value)
Implements serialization of the supplied json construct instance using the supplied json generator.
|
public static final int JSON_STRING
getType() / getJsonDataType().public static final int JSON_NUMBER
getType() / getJsonDataType().public static final int JSON_BOOLEAN
getType() / getJsonDataType().public static final int JSON_OBJECT
getType() / getJsonDataType().public static final int JSON_ARRAY
getType() / getJsonDataType().public static final int JSON_NULL
getType() / getJsonDataType().private static final JsonBackend instance
private final com.fasterxml.jackson.core.JsonFactory factory
public static JsonBackend instance()
public java.lang.String write(java.io.OutputStream target,
JsonConstruct construct,
boolean prettyPrint,
java.lang.String legacyEnc)
throws java.io.IOException
target - Target output stream.construct - The json construct instance to serialize.prettyPrint - If true the output will be formatted.legacyEnc - The character encoding name to use.java.io.IOException - in case of an IO error.public object<? extends JsonConstruct> parse(java.lang.String source) throws com.fasterxml.jackson.core.JsonParseException, java.io.IOException
source - The source text to parse.java.io.IOExceptioncom.fasterxml.jackson.core.JsonParseExceptionpublic object<? extends JsonConstruct> parse(java.io.Reader source) throws com.fasterxml.jackson.core.JsonParseException, java.io.IOException
source - The input reader to parse.java.io.IOExceptioncom.fasterxml.jackson.core.JsonParseExceptionpublic static java.lang.Object convertLegacyValueToJson(BaseDataType value)
value - The legacy value to convert.public static int getJsonDataType(java.lang.Object value)
value - Json value.public static java.lang.String getJsonDataTypeName(int type)
type - Json data type.private void writeConstruct(com.fasterxml.jackson.core.JsonGenerator jsonGen,
JsonConstruct construct)
throws java.io.IOException
jsonGen - Json generator.construct - The json construct instance to serialize.java.io.IOException - in case of an IO error.private void writeValue(com.fasterxml.jackson.core.JsonGenerator jsonGen,
java.lang.Object value)
throws java.io.IOException
jsonGen - Json generator.value - The value to serialize.java.io.IOException - in case of an IO error.private static object<? extends JsonConstruct> parseImpl(com.fasterxml.jackson.core.JsonParser parser) throws com.fasterxml.jackson.core.JsonParseException
parser - Setup json parser.com.fasterxml.jackson.core.JsonParseExceptionprivate static void checkValidConstruct(JsonConstruct con, com.fasterxml.jackson.core.JsonParser parser) throws com.fasterxml.jackson.core.JsonParseException
JsonParseException if the the argument is not a valid construct.con - the construct to check.parser - the parser to use to create the exceptioncom.fasterxml.jackson.core.JsonParseException - if the argument is nullprivate static void throwParserException(com.fasterxml.jackson.core.JsonParser parser)
throws com.fasterxml.jackson.core.JsonParseException
JsonParseException.parser - the parser to use to create the exceptioncom.fasterxml.jackson.core.JsonParseExceptionprivate static com.fasterxml.jackson.core.JsonEncoding getEncoding(java.lang.String legacyEncoding)
legacyEncoding - Legacy encoding.