| Modifier and Type | Field and Description |
|---|---|
static JsonCodec |
CODEC
This will load the default codec.
|
| Constructor and Description |
|---|
Json() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
decodeValue(Buffer buf)
Decode a given JSON buffer.
|
static <T> T |
decodeValue(Buffer buf,
Class<T> clazz)
Decode a given JSON buffer to a POJO of the given class type.
|
static Object |
decodeValue(String str)
Decode a given JSON string.
|
static <T> T |
decodeValue(String str,
Class<T> clazz)
Decode a given JSON string to a POJO of the given class type.
|
static String |
encode(Object obj)
Encode a POJO to JSON using the underlying Jackson mapper.
|
static String |
encodePrettily(Object obj)
Encode a POJO to JSON with pretty indentation, using the underlying Jackson mapper.
|
static Buffer |
encodeToBuffer(Object obj)
Encode a POJO to JSON using the underlying Jackson mapper.
|
static JsonFactory |
load()
Load the factory with the
ServiceLoader, when no factory is found then a factory
using Jackson will be returned. |
public static final JsonCodec CODEC
public static JsonFactory load()
ServiceLoader, when no factory is found then a factory
using Jackson will be returned.
jackson-databind is available then a codec using it will be used otherwise
the codec will only use jackson-core and provide best effort mapping.public static String encode(Object obj) throws EncodeException
obj - a POJOEncodeException - if a property cannot be encoded.public static Buffer encodeToBuffer(Object obj) throws EncodeException
obj - a POJOEncodeException - if a property cannot be encoded.public static String encodePrettily(Object obj) throws EncodeException
obj - a POJOEncodeException - if a property cannot be encoded.public static <T> T decodeValue(String str, Class<T> clazz) throws DecodeException
T - the generic type.str - the JSON string.clazz - the class to map to.DecodeException - when there is a parsing or invalid mapping.public static Object decodeValue(String str) throws DecodeException
str - the JSON string.JsonArray, JsonObject, String, ...etc if the content is an array, object, string, ...etcDecodeException - when there is a parsing or invalid mapping.public static Object decodeValue(Buffer buf) throws DecodeException
buf - the JSON buffer.JsonArray, JsonObject, String, ...etc if the buffer contains an array, object, string, ...etcDecodeException - when there is a parsing or invalid mapping.public static <T> T decodeValue(Buffer buf, Class<T> clazz) throws DecodeException
T - the generic type.buf - the JSON buffer.clazz - the class to map to.DecodeException - when there is a parsing or invalid mapping.Copyright © 2022 Eclipse. All rights reserved.