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> T
fromBuffer(Buffer json, Class<T> clazz)
LikefromString(String, Class)
but with a jsonBuffer
<T> T
fromString(String json, Class<T> clazz)
Decode the providejson
string to an object extendingclazz
.<T> T
fromValue(Object json, Class<T> toValueType)
LikefromString(String, Class)
but with a jsonObject
default Buffer
toBuffer(Object object)
LiketoString(Object)
but with a jsonBuffer
Buffer
toBuffer(Object object, boolean pretty)
LiketoString(Object, boolean)
but with a jsonBuffer
default String
toString(Object object)
Encode the specifiedobject
to a string.String
toString(Object object, boolean pretty)
Encode the specifiedobject
to a string.
-
-
-
Method Detail
-
fromString
<T> T fromString(String json, Class<T> clazz) throws DecodeException
Decode the providejson
string 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 specifiedobject
to a string.- Throws:
EncodeException
-
toString
String toString(Object object, boolean pretty) throws EncodeException
Encode the specifiedobject
to a string.- Parameters:
object
- the object to encodepretty
-true
to 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
-
-