public final class JsonUtil extends Object
Constructor and Description |
---|
JsonUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addArrayField(JSONObject json,
String name,
Object[] array) |
static void |
addDateField(JSONObject json,
String name,
Date date) |
static void |
addDefaultField(JSONObject json,
String name,
Object defaultValue,
Object value) |
static <T> void |
addField(JSONObject json,
String name,
JsonObjectConverter<T> converter,
T value) |
static void |
addField(JSONObject json,
String name,
Object value) |
static void |
addListField(JSONObject json,
String name,
Collection list) |
static <T> void |
addListField(JSONObject json,
String name,
JsonObjectConverter<T> converter,
List<T> list) |
static Date |
getDateField(JSONObject json,
String name) |
static List<Object> |
jsonArrayAsList(JSONArray jsonArray)
|
static <T> List<T> |
jsonArrayAsList(JSONArray jsonArray,
JsonObjectConverter<T> converter) |
static <T> T |
jsonObject(JSONObject jsonObject,
JsonObjectConverter<T> converter) |
static Map<String,Object> |
jsonObjectAsMap(JSONObject jsonObject)
Converts a
JSONObject to a Map . |
static Object |
optJavaNull(Object value)
Converts a
JSONObject.NULL to a standard Java null . |
public static Map<String,Object> jsonObjectAsMap(JSONObject jsonObject)
jsonObject
- the json object to convertpublic static List<Object> jsonArrayAsList(JSONArray jsonArray)
jsonArray
- the json array to convertpublic static Object optJavaNull(Object value)
JSONObject.NULL
to a standard Java null
.
In any other case it just returns the object as provided.value
- the object to convertnull
in case the special
marker instance JSONObject.NULL
is providedpublic static void addField(JSONObject json, String name, Object value)
public static <T> void addField(JSONObject json, String name, JsonObjectConverter<T> converter, T value)
public static void addDefaultField(JSONObject json, String name, Object defaultValue, Object value)
public static void addListField(JSONObject json, String name, Collection list)
public static <T> void addListField(JSONObject json, String name, JsonObjectConverter<T> converter, List<T> list)
public static void addArrayField(JSONObject json, String name, Object[] array)
public static void addDateField(JSONObject json, String name, Date date)
public static Date getDateField(JSONObject json, String name)
public static <T> List<T> jsonArrayAsList(JSONArray jsonArray, JsonObjectConverter<T> converter)
public static <T> T jsonObject(JSONObject jsonObject, JsonObjectConverter<T> converter)
Copyright © 2020. All rights reserved.