public class JSONUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
isPrintException |
Constructor and Description |
---|
JSONUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
getBoolean(JSONObject jsonObject,
java.lang.String key,
java.lang.Boolean defaultValue)
get Boolean from jsonObject
|
static double |
getDouble(JSONObject jsonObject,
java.lang.String key,
double defaultValue) |
static java.lang.Double |
getDouble(JSONObject jsonObject,
java.lang.String key,
java.lang.Double defaultValue)
get Double from jsonObject
|
static int |
getInt(JSONObject jsonObject,
java.lang.String key,
int defaultValue) |
static java.lang.Integer |
getInt(JSONObject jsonObject,
java.lang.String key,
java.lang.Integer defaultValue)
get Int from jsonObject
|
static JSONArray |
getJSONArray(JSONObject jsonObject,
java.lang.String key,
JSONArray defaultValue)
get JSONArray from jsonObject
|
static JSONArray |
getJSONArray(java.lang.String jsonData,
java.lang.String key,
JSONArray defaultValue)
get JSONArray from jsonData
|
static JSONObject |
getJSONObject(JSONObject jsonObject,
java.lang.String key,
JSONObject defaultValue)
get JSONObject from jsonObject
|
static JSONObject |
getJSONObject(java.lang.String jsonData,
java.lang.String key,
JSONObject defaultValue)
get JSONObject from jsonData
|
static long |
getLong(JSONObject jsonObject,
java.lang.String key,
long defaultValue) |
static java.lang.Long |
getLong(JSONObject jsonObject,
java.lang.String key,
java.lang.Long defaultValue)
get Long from jsonObject
|
static java.util.Map<java.lang.String,java.lang.String> |
getMap(JSONObject jsonObject,
java.lang.String key)
get map from jsonObject.
|
static java.lang.String |
getString(JSONObject jsonObject,
java.lang.String key,
java.lang.String defaultValue)
get String from jsonObject
|
static java.lang.String[] |
getStringArray(JSONObject jsonObject,
java.lang.String key,
java.lang.String[] defaultValue)
get String array from jsonObject
|
static java.util.Map<java.lang.String,java.lang.String> |
parseKeyAndValueToMap(JSONObject sourceObj)
parse key-value pairs to map. ignore empty key, if getValue exception, put empty value
|
public static java.lang.Long getLong(JSONObject jsonObject, java.lang.String key, java.lang.Long defaultValue)
jsonObject
- key
- defaultValue
- JSONObject#getLong(String)
exception, return defaultValueJSONObject#getLong(String)
public static long getLong(JSONObject jsonObject, java.lang.String key, long defaultValue)
jsonObject
- key
- defaultValue
- getLong(JSONObject, String, Long)
public static java.lang.Integer getInt(JSONObject jsonObject, java.lang.String key, java.lang.Integer defaultValue)
jsonObject
- key
- defaultValue
- JSONObject#getInt(String)
exception, return defaultValueJSONObject#getInt(String)
public static int getInt(JSONObject jsonObject, java.lang.String key, int defaultValue)
jsonObject
- key
- defaultValue
- getInt(JSONObject, String, Integer)
public static java.lang.Double getDouble(JSONObject jsonObject, java.lang.String key, java.lang.Double defaultValue)
jsonObject
- key
- defaultValue
- JSONObject#getDouble(String)
exception, return defaultValueJSONObject#getDouble(String)
public static double getDouble(JSONObject jsonObject, java.lang.String key, double defaultValue)
jsonObject
- key
- defaultValue
- getDouble(JSONObject, String, Double)
public static java.lang.String getString(JSONObject jsonObject, java.lang.String key, java.lang.String defaultValue)
jsonObject
- key
- defaultValue
- JSONObject#getString(String)
exception, return defaultValueJSONObject#getString(String)
public static java.lang.String[] getStringArray(JSONObject jsonObject, java.lang.String key, java.lang.String[] defaultValue)
jsonObject
- key
- defaultValue
- JSONObject#getJSONArray(String)
exception, return defaultValueJSONArray#getString(int)
exception, return defaultValuepublic static JSONObject getJSONObject(JSONObject jsonObject, java.lang.String key, JSONObject defaultValue)
jsonObject
- key
- defaultValue
- JSONObject#getJSONObject(String)
exception, return defaultValueJSONObject#getJSONObject(String)
public static JSONObject getJSONObject(java.lang.String jsonData, java.lang.String key, JSONObject defaultValue)
jsonData
- key
- defaultValue
- JSONObject#JSONObject(String)
exception, return defaultValuegetJSONObject(JSONObject, String, JSONObject)
public static JSONArray getJSONArray(JSONObject jsonObject, java.lang.String key, JSONArray defaultValue)
jsonObject
- key
- defaultValue
- JSONObject#getJSONArray(String)
exception, return defaultValueJSONObject#getJSONArray(String)
public static JSONArray getJSONArray(java.lang.String jsonData, java.lang.String key, JSONArray defaultValue)
jsonData
- key
- defaultValue
- JSONObject#JSONObject(String)
exception, return defaultValueJSONUtils#getJSONArray(JSONObject, String, JSONObject)
public static boolean getBoolean(JSONObject jsonObject, java.lang.String key, java.lang.Boolean defaultValue)
jsonObject
- key
- defaultValue
- JSONObject#getBoolean(String)
public static java.util.Map<java.lang.String,java.lang.String> getMap(JSONObject jsonObject, java.lang.String key)
jsonObject
- key-value pairs jsonkey
- JSONUtils#parseKeyAndValueToMap(String)
public static java.util.Map<java.lang.String,java.lang.String> parseKeyAndValueToMap(JSONObject sourceObj)
sourceObj
- key-value pairs jsonMapUtils.putMapNotEmptyKey(Map, String, String)
one by one