Package xal.tools.coding.json
Class JSONCoder
java.lang.Object
xal.tools.coding.json.JSONCoder
- All Implemented Interfaces:
Coder
encode and decode objects with JSON
-
Method Summary
Modifier and TypeMethodDescriptionDecode the JSON stringstatic Object
defaultDecode
(String archive) Decode the JSON string using the default coderstatic String
defaultEncode
(Object value) Encode the object as a JSON string using the default encoderEncode the object as a JSON stringprotected ConversionAdaptor<?,
?> getConversionAdaptor
(String valueType) Get the conversion adaptor for the given valueGet a list of types (including JSON standard types plus default extensions) which are supported for coding and decodingGet a list of types which extend beyond the JSON standard typesstatic JSONCoder
get a new JSON Coder only if you need to customize it, otherwise use the static methods to encode/decodeGet a list of the standard types encoded directly into JSONGet a list of all types which are supported for coding and decodingstatic boolean
isStandardType
(String type) Determine whether the specified type is a standard JSON type<C,
R> void registerType
(Class<C> type, ConversionAdaptor<C, R> adaptor) Register the custom type by class and its associated adaptor
-
Method Details
-
getInstance
get a new JSON Coder only if you need to customize it, otherwise use the static methods to encode/decode -
getDefaultTypes
Get a list of types (including JSON standard types plus default extensions) which are supported for coding and decoding -
getStandardTypes
Get a list of the standard types encoded directly into JSON -
isStandardType
Determine whether the specified type is a standard JSON type -
getSupportedTypes
Get a list of all types which are supported for coding and decoding- Specified by:
getSupportedTypes
in interfaceCoder
-
getExtendedTypes
Get a list of types which extend beyond the JSON standard types -
registerType
Register the custom type by class and its associated adaptor- Specified by:
registerType
in interfaceCoder
- Parameters:
type
- type to identify and process for encoding and decodingadaptor
- translator between the custom type and representation JSON constructs
-
getConversionAdaptor
Get the conversion adaptor for the given value -
defaultDecode
Decode the JSON string using the default coder- Parameters:
archive
- JSON string representation of an object- Returns:
- an object with the data described in the archive
-
decode
Decode the JSON string -
defaultEncode
Encode the object as a JSON string using the default encoder- Parameters:
value
- the object to encode- Returns:
- a JSON string representing the value
-
encode
Encode the object as a JSON string
-