Package io.vertx.core.json.jackson
Class JacksonCodec
- java.lang.Object
-
- io.vertx.core.json.jackson.JacksonCodec
-
- All Implemented Interfaces:
JsonCodec
- Direct Known Subclasses:
DatabindCodec
public class JacksonCodec extends Object implements JsonCodec
- Author:
- Julien Viet
-
-
Constructor Summary
Constructors Constructor Description JacksonCodec()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonParsercreateParser(Buffer buf)static JsonParsercreateParser(String str)static voidencodeJson(Object json, JsonGenerator generator)ObjectfromBuffer(Buffer buf)<T> TfromBuffer(Buffer json, Class<T> clazz)LikeJsonCodec.fromString(String, Class)but with a jsonBufferstatic <T> TfromParser(JsonParser parser, Class<T> type)ObjectfromString(String str)<T> TfromString(String json, Class<T> clazz)Decode the providejsonstring to an object extendingclazz.<T> TfromValue(Object json, Class<T> toValueType)LikeJsonCodec.fromString(String, Class)but with a jsonObjectBuffertoBuffer(Object object, boolean pretty)LikeJsonCodec.toString(Object, boolean)but with a jsonBufferStringtoString(Object object, boolean pretty)Encode the specifiedobjectto a string.
-
-
-
Method Detail
-
fromString
public <T> T fromString(String json, Class<T> clazz) throws DecodeException
Description copied from interface:JsonCodecDecode the providejsonstring to an object extendingclazz.- Specified by:
fromStringin interfaceJsonCodec- Parameters:
json- the json stringclazz- the required object's class- Returns:
- the instance
- Throws:
DecodeException- anything preventing the decoding
-
fromBuffer
public <T> T fromBuffer(Buffer json, Class<T> clazz) throws DecodeException
Description copied from interface:JsonCodecLikeJsonCodec.fromString(String, Class)but with a jsonBuffer- Specified by:
fromBufferin interfaceJsonCodec- Throws:
DecodeException
-
fromValue
public <T> T fromValue(Object json, Class<T> toValueType)
Description copied from interface:JsonCodecLikeJsonCodec.fromString(String, Class)but with a jsonObject
-
toString
public String toString(Object object, boolean pretty) throws EncodeException
Description copied from interface:JsonCodecEncode the specifiedobjectto a string.- Specified by:
toStringin interfaceJsonCodec- Parameters:
object- the object to encodepretty-trueto 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:JsonCodecLikeJsonCodec.toString(Object, boolean)but with a jsonBuffer- Specified by:
toBufferin interfaceJsonCodec- Throws:
EncodeException
-
createParser
public static JsonParser createParser(String str)
-
createParser
public static JsonParser createParser(Buffer buf)
-
fromString
public Object fromString(String str) throws DecodeException
- Throws:
DecodeException
-
fromBuffer
public Object fromBuffer(Buffer buf) throws DecodeException
- Throws:
DecodeException
-
fromParser
public static <T> T fromParser(JsonParser parser, Class<T> type) throws DecodeException
- Throws:
DecodeException
-
encodeJson
public static void encodeJson(Object json, JsonGenerator generator) throws EncodeException
- Throws:
EncodeException
-
-