Package io.vertx.core.json.jackson
Class DatabindCodec
- java.lang.Object
-
- io.vertx.core.json.jackson.JacksonCodec
-
- io.vertx.core.json.jackson.DatabindCodec
-
- All Implemented Interfaces:
JsonCodec
public class DatabindCodec extends JacksonCodec
- Author:
- Julien Viet
-
-
Constructor Summary
Constructors Constructor Description DatabindCodec()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonParser
createParser(io.vertx.core.internal.buffer.BufferInternal buf)
static JsonParser
createParser(String str)
<T> T
fromBuffer(Buffer buf, TypeReference<T> typeRef)
<T> T
fromBuffer(Buffer buf, Class<T> clazz)
LikeJsonCodec.fromString(String, Class)
but with a jsonBuffer
static <T> T
fromParser(JsonParser parser, Class<T> type)
<T> T
fromString(String str, TypeReference<T> typeRef)
<T> T
fromString(String str, Class<T> clazz)
Decode the providejson
string to an object extendingclazz
.<T> T
fromValue(Object json, TypeReference<T> type)
<T> T
fromValue(Object json, Class<T> clazz)
LikeJsonCodec.fromString(String, Class)
but with a jsonObject
static ObjectMapper
mapper()
Buffer
toBuffer(Object object, boolean pretty)
LikeJsonCodec.toString(Object, boolean)
but with a jsonBuffer
String
toString(Object object, boolean pretty)
Encode the specifiedobject
to a string.-
Methods inherited from class io.vertx.core.json.jackson.JacksonCodec
createParser, decodeValue, decodeValue, encodeJson, fromBuffer, fromString
-
-
-
-
Method Detail
-
mapper
public static ObjectMapper mapper()
- Returns:
- the
ObjectMapper
used for data binding.
-
fromValue
public <T> T fromValue(Object json, Class<T> clazz)
Description copied from interface:JsonCodec
LikeJsonCodec.fromString(String, Class)
but with a jsonObject
- Specified by:
fromValue
in interfaceJsonCodec
- Overrides:
fromValue
in classJacksonCodec
-
fromValue
public <T> T fromValue(Object json, TypeReference<T> type)
- Overrides:
fromValue
in classJacksonCodec
-
fromString
public <T> T fromString(String str, Class<T> clazz) throws DecodeException
Description copied from interface:JsonCodec
Decode the providejson
string to an object extendingclazz
.- Specified by:
fromString
in interfaceJsonCodec
- Overrides:
fromString
in classJacksonCodec
- Parameters:
str
- the json stringclazz
- the required object's class- Returns:
- the instance
- Throws:
DecodeException
- anything preventing the decoding
-
fromString
public <T> T fromString(String str, TypeReference<T> typeRef) throws DecodeException
- Overrides:
fromString
in classJacksonCodec
- Throws:
DecodeException
-
fromBuffer
public <T> T fromBuffer(Buffer buf, Class<T> clazz) throws DecodeException
Description copied from interface:JsonCodec
LikeJsonCodec.fromString(String, Class)
but with a jsonBuffer
- Specified by:
fromBuffer
in interfaceJsonCodec
- Overrides:
fromBuffer
in classJacksonCodec
- Throws:
DecodeException
-
fromBuffer
public <T> T fromBuffer(Buffer buf, TypeReference<T> typeRef) throws DecodeException
- Overrides:
fromBuffer
in classJacksonCodec
- Throws:
DecodeException
-
createParser
public static JsonParser createParser(io.vertx.core.internal.buffer.BufferInternal buf)
-
createParser
public static JsonParser createParser(String str)
-
fromParser
public static <T> T fromParser(JsonParser parser, Class<T> type) throws DecodeException
- Throws:
DecodeException
-
toString
public String toString(Object object, boolean pretty) throws EncodeException
Description copied from interface:JsonCodec
Encode the specifiedobject
to a string.- Specified by:
toString
in interfaceJsonCodec
- Overrides:
toString
in classJacksonCodec
- Parameters:
object
- the object to encodepretty
-true
to format the string prettily- Returns:
- the json encoded string
- Throws:
EncodeException
-
toBuffer
public Buffer toBuffer(Object object, boolean pretty) throws EncodeException
Description copied from interface:JsonCodec
LikeJsonCodec.toString(Object, boolean)
but with a jsonBuffer
- Specified by:
toBuffer
in interfaceJsonCodec
- Overrides:
toBuffer
in classJacksonCodec
- Throws:
EncodeException
-
-