public class JsonTools
A singleton object that decodes and encodes JSON.
Modifier and Type | Field and Description |
---|---|
static JsonTools |
INSTANCE
A singleton object that decodes and encodes JSON.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
decode(java.lang.String json,
java.lang.Class<T> clazz)
Decodes a JSON string to an object.
|
java.lang.String |
encode(java.lang.Object value)
Encodes a JSON object to a string.
|
public static JsonTools INSTANCE
A singleton object that decodes and encodes JSON.
public <T> T decode(@NotNull java.lang.String json, @NotNull java.lang.Class<T> clazz)
Decodes a JSON string to an object.
T
- The type of the object to decode the JSON string to.
json
- The JSON string to decode.clazz
- The class of the object to decode the JSON string to.Exception
- If an error occurs while decoding the JSON string.@NotNull public java.lang.String encode(@NotNull java.lang.Object value)
Encodes a JSON object to a string.
value
- The JSON object to encode.Exception
- If an error occurs while encoding the JSON object.