Package io.vertx.core.spi.json
Interface JsonCodec
-
- All Known Implementing Classes:
DatabindCodec,JacksonCodec
public interface JsonCodec- Author:
- Julien Viet
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> TfromBuffer(Buffer json, Class<T> clazz)LikefromString(String, Class)but with a jsonBuffer<T> TfromString(String json, Class<T> clazz)Decode the providejsonstring to an object extendingclazz.<T> TfromValue(Object json, Class<T> toValueType)LikefromString(String, Class)but with a jsonObjectdefault BuffertoBuffer(Object object)LiketoString(Object)but with a jsonBufferBuffertoBuffer(Object object, boolean pretty)LiketoString(Object, boolean)but with a jsonBufferdefault StringtoString(Object object)Encode the specifiedobjectto a string.StringtoString(Object object, boolean pretty)Encode the specifiedobjectto a string.
-
-
-
Method Detail
-
fromString
<T> T fromString(String json, Class<T> clazz) throws DecodeException
Decode the providejsonstring to an object extendingclazz.- Parameters:
json- the json stringclazz- the required object's class- Returns:
- the instance
- Throws:
DecodeException- anything preventing the decoding
-
fromBuffer
<T> T fromBuffer(Buffer json, Class<T> clazz) throws DecodeException
LikefromString(String, Class)but with a jsonBuffer- Throws:
DecodeException
-
fromValue
<T> T fromValue(Object json, Class<T> toValueType)
LikefromString(String, Class)but with a jsonObject
-
toString
default String toString(Object object) throws EncodeException
Encode the specifiedobjectto a string.- Throws:
EncodeException
-
toString
String toString(Object object, boolean pretty) throws EncodeException
Encode the specifiedobjectto a string.- Parameters:
object- the object to encodepretty-trueto format the string prettily- Returns:
- the json encoded string
- Throws:
DecodeException- anything preventing the encodingEncodeException
-
toBuffer
Buffer toBuffer(Object object, boolean pretty) throws EncodeException
LiketoString(Object, boolean)but with a jsonBuffer- Throws:
EncodeException
-
toBuffer
default Buffer toBuffer(Object object) throws EncodeException
LiketoString(Object)but with a jsonBuffer- Throws:
EncodeException
-
-