Class DatabindCodec
java.lang.Object
io.vertx.core.json.jackson.JacksonCodec
io.vertx.core.json.jackson.DatabindCodec
- All Implemented Interfaces:
JsonCodec
- Author:
- Julien Viet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonParsercreateParser(io.vertx.core.internal.buffer.BufferInternal buf) static JsonParsercreateParser(String str) <T> TfromBuffer(Buffer buf, TypeReference<T> typeRef) <T> TfromBuffer(Buffer buf, Class<T> clazz) LikeJsonCodec.fromString(String, Class)but with a jsonBufferstatic <T> TfromParser(JsonParser parser, Class<T> type) <T> TfromReader(Reader reader, Class<T> clazz) Decode JSON from the givenReaderto an object of the specified type.<T> TfromStream(InputStream in, Class<T> clazz) Decode JSON from the givenInputStreamto an object of the specified type.<T> TfromString(String str, TypeReference<T> typeRef) <T> TfromString(String str, Class<T> clazz) Decode the providejsonstring to an object extendingclazz.<T> TfromValue(Object json, TypeReference<T> type) <T> TLikeJsonCodec.fromString(String, Class)but with a jsonObjectstatic ObjectMappermapper()LikeJsonCodec.toString(Object, boolean)but with a jsonBuffervoidtoStream(Object object, OutputStream out) Encode the specified object as JSON to the givenOutputStream.Encode the specifiedobjectto a string.voidEncode the specified object as JSON to the givenWriter.Methods inherited from class JacksonCodec
createParser, encodeJson, fromBuffer, fromString, parseArray, parseObject, parseValueMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface JsonCodec
fromReader, fromStream, toBuffer, toString
-
Constructor Details
-
DatabindCodec
public DatabindCodec()
-
-
Method Details
-
mapper
- Returns:
- the
ObjectMapperused for data binding.
-
fromValue
Description copied from interface:JsonCodecLikeJsonCodec.fromString(String, Class)but with a jsonObject- Specified by:
fromValuein interfaceJsonCodec- Overrides:
fromValuein classJacksonCodec
-
fromValue
-
fromString
Description copied from interface:JsonCodecDecode the providejsonstring to an object extendingclazz.- Specified by:
fromStringin interfaceJsonCodec- Overrides:
fromStringin classJacksonCodec- Parameters:
str- the json stringclazz- the required object's class- Returns:
- the instance
- Throws:
DecodeException- anything preventing the decoding
-
fromString
- Throws:
DecodeException
-
fromBuffer
Description copied from interface:JsonCodecLikeJsonCodec.fromString(String, Class)but with a jsonBuffer- Specified by:
fromBufferin interfaceJsonCodec- Overrides:
fromBufferin classJacksonCodec- Throws:
DecodeException
-
fromBuffer
- Throws:
DecodeException
-
fromStream
Description copied from interface:JsonCodecDecode JSON from the givenInputStreamto an object of the specified type.The input is expected to be UTF-8 encoded.
The codec does not close or flush the stream; the caller retains ownership.
- Specified by:
fromStreamin interfaceJsonCodec- Overrides:
fromStreamin classJacksonCodec- Parameters:
in- the input stream containing UTF-8 encoded JSONclazz- the required object's class- Returns:
- the decoded instance
- Throws:
DecodeException- anything preventing the decoding
-
createParser
-
createParser
-
fromParser
- Throws:
DecodeException
-
toString
Description copied from interface:JsonCodecEncode the specifiedobjectto a string.- Specified by:
toStringin interfaceJsonCodec- Overrides:
toStringin classJacksonCodec- Parameters:
object- the object to encodepretty-trueto format the string prettily- Returns:
- the json encoded string
- Throws:
EncodeException
-
toBuffer
Description copied from interface:JsonCodecLikeJsonCodec.toString(Object, boolean)but with a jsonBuffer- Specified by:
toBufferin interfaceJsonCodec- Overrides:
toBufferin classJacksonCodec- Throws:
EncodeException
-
toStream
Description copied from interface:JsonCodecEncode the specified object as JSON to the givenOutputStream.The output is UTF-8 encoded.
The codec does not close or flush the stream; the caller retains ownership.
- Specified by:
toStreamin interfaceJsonCodec- Overrides:
toStreamin classJacksonCodec- Parameters:
object- the object to encodeout- the output stream to write to- Throws:
EncodeException- anything preventing the encoding
-
fromReader
Description copied from interface:JsonCodecDecode JSON from the givenReaderto an object of the specified type.The codec does not close or flush the reader; the caller retains ownership.
- Specified by:
fromReaderin interfaceJsonCodec- Overrides:
fromReaderin classJacksonCodec- Parameters:
reader- the reader containing JSON textclazz- the required object's class- Returns:
- the decoded instance
- Throws:
DecodeException- anything preventing the decoding
-
toWriter
Description copied from interface:JsonCodecEncode the specified object as JSON to the givenWriter.The codec does not close or flush the writer; the caller retains ownership.
- Specified by:
toWriterin interfaceJsonCodec- Overrides:
toWriterin classJacksonCodec- Parameters:
object- the object to encodewriter- the writer to write to- Throws:
EncodeException- anything preventing the encoding
-