public interface JsonCodec
Modifier and Type | Field and Description |
---|---|
static JsonCodec |
INSTANCE
Static cached codec instance, initialized with
loadCodec() . |
Modifier and Type | Method and Description |
---|---|
<T> T |
fromBuffer(Buffer json,
Class<T> clazz)
Like
fromString(String, Class) but with a json Buffer |
<T> T |
fromString(String json,
Class<T> clazz)
Decode the provide
json string to an object extending clazz . |
<T> T |
fromValue(Object json,
Class<T> toValueType)
Like
fromString(String, Class) but with a json Object |
static JsonCodec |
loadCodec()
Load the JSON codec with the
ServiceLoader
An attempt is made to load a factory using the service loader META-INF/services JsonCodec .
Codecs are sorted
If no codec is resolved (which is usually the default case), the a JacksonCodec is created and used.
|
default int |
order()
The order of the codec.
|
default Buffer |
toBuffer(Object object)
Like
toString(Object) but with a json Buffer |
Buffer |
toBuffer(Object object,
boolean pretty)
Like
toString(Object, boolean) but with a json Buffer |
default String |
toString(Object object)
Encode the specified
object to a string. |
String |
toString(Object object,
boolean pretty)
Encode the specified
object to a string. |
static final JsonCodec INSTANCE
loadCodec()
.static JsonCodec loadCodec()
Load the JSON codec with the ServiceLoader
META-INF/services
JsonCodec
.JacksonCodec
is created and used.default int order()
<T> T fromString(String json, Class<T> clazz) throws DecodeException
json
string to an object extending clazz
.json
- the json stringclazz
- the required object's classDecodeException
- anything preventing the decoding<T> T fromBuffer(Buffer json, Class<T> clazz) throws DecodeException
fromString(String, Class)
but with a json Buffer
DecodeException
<T> T fromValue(Object json, Class<T> toValueType)
fromString(String, Class)
but with a json Object
default String toString(Object object) throws EncodeException
object
to a string.EncodeException
String toString(Object object, boolean pretty) throws EncodeException
object
to a string.object
- the object to encodepretty
- true
to format the string prettilyDecodeException
- anything preventing the encodingEncodeException
Buffer toBuffer(Object object, boolean pretty) throws EncodeException
toString(Object, boolean)
but with a json Buffer
EncodeException
default Buffer toBuffer(Object object) throws EncodeException
toString(Object)
but with a json Buffer
EncodeException
Copyright © 2023 Eclipse. All rights reserved.