public final class JsonUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static com.google.gson.Gson |
GSON |
| Constructor and Description |
|---|
JsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
decode(String json,
Class<T> cls)
Attempt to decode a JSON string as a Java object
|
static List |
decodeAsList(String json)
Decode a JSON string as a Java list.
|
static Map<String,Object> |
decodeAsMap(String json)
Decode a JSON string as Java map.
|
static String |
encode(Object obj)
Encode a Java object as JSON
|
public static String encode(Object obj)
obj - The object to encodepublic static <T> T decode(String json, Class<T> cls)
T - Class parameterjson - The JSON string to decodecls - The class to decode ascls, or an exceptionpublic static List decodeAsList(String json)
json - The JSON to decodeCopyright © 2017. All rights reserved.