public class JSONHandler extends Object
Constructor and Description |
---|
JSONHandler() |
Modifier and Type | Method and Description |
---|---|
static Object |
get(org.json.JSONObject json,
String param,
Class type)
Gets a JSON element.
|
static Boolean |
getBoolean(org.json.JSONObject json,
String param)
Gets a Boolean.
|
static org.json.JSONObject |
getFormatedJSONObjectMap(Map map)
Gets a formatted JSON Object from a JSONObject map.
|
static Integer |
getInteger(org.json.JSONObject json,
String param)
Gets an Integer.
|
static org.json.JSONArray |
getJSONArrayFromArray(Object[] array)
Gets a JSON Array from an array.
|
static org.json.JSONArray |
getJSONArrayFromCollection(Collection collection)
Gets a JSON Array from a collection.
|
static Map |
getJSONArrayMap(org.json.JSONObject json)
Gets a JSONArray map.
|
static Map |
getJSONArrayMap(org.json.JSONObject json,
String param)
Gets a JSONArray map.
|
static org.json.JSONObject |
getJSONObject(org.json.JSONObject json,
String param)
Gets a JSON Object.
|
static org.json.JSONObject[] |
getJSONObjectArray(org.json.JSONObject json,
String param)
Gets a JSONObject array.
|
static org.json.JSONObject |
getJSONObjectFromListMap(Map map)
Gets a JSON Object from a List map.
|
static Map |
getJSONObjectMap(org.json.JSONObject json)
Gets a JSONObject map.
|
static Map |
getJSONObjectMap(org.json.JSONObject json,
String param)
Gets a JSONObject map.
|
static String |
getString(org.json.JSONObject json,
String param)
Gets a String.
|
static String[] |
getStringArray(org.json.JSONArray jsonArray)
Gets a String array.
|
static String[] |
getStringArray(org.json.JSONObject json,
String param)
Gets a String array.
|
static void |
set(org.json.JSONObject json,
String param,
Object value)
Sets a JSON element.
|
static void |
setNull(org.json.JSONObject json,
String param)
Sets a JSON element to null.
|
public static Object get(org.json.JSONObject json, String param, Class type)
json
- JSON Objectparam
- Parameter name (for example, "sessionId")type
- Data type (primitives or json.org type)public static void set(org.json.JSONObject json, String param, Object value)
json
- JSON Objectparam
- Parameter name (for example, "sessionId")value
- Value to setpublic static void setNull(org.json.JSONObject json, String param)
json
- JSON Objectparam
- Parameter name (for example, "dataChannelConfig")public static String getString(org.json.JSONObject json, String param)
json
- JSON Objectparam
- Parameter name (for example, "sessionId")public static Integer getInteger(org.json.JSONObject json, String param)
json
- JSON Objectparam
- Parameter name (for example, "lastOutboundSeq")public static Boolean getBoolean(org.json.JSONObject json, String param)
json
- JSON Objectparam
- Parameter namepublic static org.json.JSONObject getJSONObject(org.json.JSONObject json, String param)
json
- JSON Objectparam
- Parameter name (for example, "call")public static String[] getStringArray(org.json.JSONObject json, String param) throws org.json.JSONException
json
- JSON Objectparam
- Parameter nameorg.json.JSONException
public static String[] getStringArray(org.json.JSONArray jsonArray) throws org.json.JSONException
jsonArray
- a JSON Arrayorg.json.JSONException
public static org.json.JSONObject[] getJSONObjectArray(org.json.JSONObject json, String param) throws org.json.JSONException
json
- JSON Objectparam
- Parameter nameorg.json.JSONException
public static Map getJSONObjectMap(org.json.JSONObject json, String param) throws org.json.JSONException
json
- JSON Objectparam
- Parameter nameorg.json.JSONException
public static Map getJSONObjectMap(org.json.JSONObject json) throws org.json.JSONException
json
- JSON Objectorg.json.JSONException
public static Map getJSONArrayMap(org.json.JSONObject json, String param) throws org.json.JSONException
json
- JSON Objectparam
- Parameter nameorg.json.JSONException
public static Map getJSONArrayMap(org.json.JSONObject json) throws org.json.JSONException
json
- JSON Objectorg.json.JSONException
public static org.json.JSONObject getJSONObjectFromListMap(Map map) throws org.json.JSONException
map
- a List maporg.json.JSONException
public static org.json.JSONObject getFormatedJSONObjectMap(Map map) throws org.json.JSONException
map
- a JSONObject maporg.json.JSONException
public static org.json.JSONArray getJSONArrayFromCollection(Collection collection)
collection
- a collectionpublic static org.json.JSONArray getJSONArrayFromArray(Object[] array)
array
- a object array