public class JacksonCodec extends Object implements JsonCodec
Constructor and Description |
---|
JacksonCodec() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
decodeValue(Buffer buf,
TypeReference<T> type)
Decode a given JSON buffer to a POJO of the given class type.
|
static <T> T |
decodeValue(String str,
TypeReference<T> type)
Decode a given JSON string to a POJO of the given type.
|
<T> T |
fromBuffer(Buffer buf,
Class<T> clazz)
Like
JsonCodec.fromString(String, Class) but with a json Buffer |
static <T> T |
fromBuffer(Buffer buf,
TypeReference<T> type) |
<T> T |
fromString(String str,
Class<T> clazz)
Decode the provide
json string to an object extending clazz . |
static <T> T |
fromString(String str,
TypeReference<T> type) |
<T> T |
fromValue(Object json,
Class<T> clazz)
Like
JsonCodec.fromString(String, Class) but with a json Object |
static <T> T |
fromValue(Object json,
TypeReference<T> type) |
Buffer |
toBuffer(Object object,
boolean pretty)
Like
JsonCodec.toString(Object, boolean) but with a json Buffer |
String |
toString(Object object,
boolean pretty)
Encode the specified
object to a string. |
public <T> T fromValue(Object json, Class<T> clazz)
JsonCodec
JsonCodec.fromString(String, Class)
but with a json Object
public static <T> T fromValue(Object json, TypeReference<T> type)
public <T> T fromString(String str, Class<T> clazz) throws DecodeException
JsonCodec
json
string to an object extending clazz
.fromString
in interface JsonCodec
str
- the json stringclazz
- the required object's classDecodeException
- anything preventing the decodingpublic static <T> T fromString(String str, TypeReference<T> type) throws DecodeException
DecodeException
public <T> T fromBuffer(Buffer buf, Class<T> clazz) throws DecodeException
JsonCodec
JsonCodec.fromString(String, Class)
but with a json Buffer
fromBuffer
in interface JsonCodec
DecodeException
public static <T> T fromBuffer(Buffer buf, TypeReference<T> type) throws DecodeException
DecodeException
public String toString(Object object, boolean pretty) throws EncodeException
JsonCodec
object
to a string.toString
in interface JsonCodec
object
- the object to encodepretty
- true
to format the string prettilyEncodeException
public Buffer toBuffer(Object object, boolean pretty) throws EncodeException
JsonCodec
JsonCodec.toString(Object, boolean)
but with a json Buffer
toBuffer
in interface JsonCodec
EncodeException
public static <T> T decodeValue(String str, TypeReference<T> type) throws DecodeException
T
- the generic type.str
- the JSON string.type
- the type to map to.DecodeException
- when there is a parsing or invalid mapping.public static <T> T decodeValue(Buffer buf, TypeReference<T> type) throws DecodeException
T
- the generic type.buf
- the JSON buffer.type
- the type to map to.DecodeException
- when there is a parsing or invalid mapping.Copyright © 2023 Eclipse. All rights reserved.