public class JacksonCodec extends Object implements JsonCodec
Constructor and Description |
---|
JacksonCodec() |
Modifier and Type | Method and Description |
---|---|
static JsonParser |
createParser(Buffer buf) |
static JsonParser |
createParser(String str) |
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.
|
Object |
fromBuffer(Buffer buf) |
<T> T |
fromBuffer(Buffer json,
Class<T> clazz)
Like
JsonCodec.fromString(String, Class) but with a json Buffer |
<T> T |
fromBuffer(Buffer buf,
TypeReference<T> typeRef) |
static <T> T |
fromParser(JsonParser parser,
Class<T> type) |
Object |
fromString(String str) |
<T> T |
fromString(String json,
Class<T> clazz)
Decode the provide
json string to an object extending clazz . |
<T> T |
fromString(String str,
TypeReference<T> typeRef) |
<T> T |
fromValue(Object json,
Class<T> toValueType)
Like
JsonCodec.fromString(String, Class) but with a json Object |
<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 fromString(String json, Class<T> clazz) throws DecodeException
JsonCodec
json
string to an object extending clazz
.fromString
in interface JsonCodec
json
- the json stringclazz
- the required object's classDecodeException
- anything preventing the decodingpublic <T> T fromString(String str, TypeReference<T> typeRef) throws DecodeException
DecodeException
public <T> T fromBuffer(Buffer json, Class<T> clazz) throws DecodeException
JsonCodec
JsonCodec.fromString(String, Class)
but with a json Buffer
fromBuffer
in interface JsonCodec
DecodeException
public <T> T fromBuffer(Buffer buf, TypeReference<T> typeRef) throws DecodeException
DecodeException
public <T> T fromValue(Object json, Class<T> toValueType)
JsonCodec
JsonCodec.fromString(String, Class)
but with a json Object
public <T> T fromValue(Object json, TypeReference<T> type)
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 JsonParser createParser(String str)
public static JsonParser createParser(Buffer buf)
public Object fromString(String str) throws DecodeException
DecodeException
public Object fromBuffer(Buffer buf) throws DecodeException
DecodeException
public static <T> T fromParser(JsonParser parser, Class<T> type) throws DecodeException
DecodeException
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.