public class JsonUtil
extends java.lang.Object
| Constructor and Description |
|---|
JsonUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.lang.Object> |
fromJson(org.json.JSONArray array)
Converts a
JSONArray to a List. |
static java.util.Map<java.lang.String,java.lang.Object> |
fromJson(org.json.JSONObject object)
Converts a
JSONObject to a Map. |
static java.lang.Object |
toJson(java.lang.Object object)
Converts a Java object to a JSON object.
|
public static java.lang.Object toJson(java.lang.Object object)
throws org.json.JSONException
Map is
converted to a JSONObject, a List or
array is converted to a JSONArray,
and null is converted to JSONObject.NULL.
Other objects, like Number, String,
and Boolean are returned without conversion.object - The object to convert.org.json.JSONException - If the object cannot be converted.public static java.util.Map<java.lang.String,java.lang.Object> fromJson(org.json.JSONObject object)
JSONObject to a Map.object - The JSON object to convert.null if the object is null.org.json.JSONException - If the object cannot be converted.public static java.util.List<java.lang.Object> fromJson(org.json.JSONArray array)
JSONArray to a List.array - The JSON array to convert.null if the array is null.org.json.JSONException - If the array cannot be converted.