|
Spiffy UI Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.spiffyui.client.JSONUtil
public final class JSONUtil
A set of static JavaScript utilities for handling JSON data structures.
Method Summary | |
---|---|
static boolean |
containsKeyIgnoreCase(JSONObject obj,
java.lang.String key)
Determines if the specified JSONObject contains the specified key. |
static boolean |
getBooleanValue(JSONObject obj,
java.lang.String key)
Get a boolean from the JSON object false if it doesn't exist or isn't a boolean |
static boolean |
getBooleanValue(JSONObject obj,
java.lang.String key,
boolean defaultValue)
Get a boolean from the JSON object or defaultValue if it doesn't exist or isn't a boolean |
static java.util.Date |
getDateValue(JSONObject obj,
java.lang.String key)
Get a java.util.Date from the JSON object as an epoch time in milliseconds or return null if it doesn't exist or cannot be converted from epoch to Date |
static double |
getDoubleValue(JSONObject obj,
java.lang.String key)
Get a double from the JSON object or 0 if it doesn't exist or isn't a double. |
static double |
getDoubleValue(JSONObject obj,
java.lang.String key,
double defaultValue)
Get a double from the JSON object or the defaultValue if it doesn't exist or isn't a double. |
static JSONValue |
getIgnoreCase(JSONObject obj,
java.lang.String key)
Get the JSONValue from the specified object ignoring the case of the key. |
static int |
getIntValue(JSONObject obj,
java.lang.String key)
Get an int from the JSON object or -1 if it doesn't exist or isn't an int. |
static int |
getIntValue(JSONObject obj,
java.lang.String key,
int defaultValue)
Get an int from the JSON object or the defaultValue if it doesn't exist or isn't an int. |
static JSONArray |
getJSONArray(JSONObject obj,
java.lang.String key)
Get a JSONArray from the JSON object or null if it doesn't exist or isn't a JSONArray |
static JSONObject |
getJSONObject(JSONObject obj,
java.lang.String key)
Get a JSONObject from the JSON object or null if it doesn't exist or isn't a JSONObject |
static long |
getLongValue(JSONObject obj,
java.lang.String key)
Get a long from the JSON object or -1 if it doesn't exist or isn't a long. |
static long |
getLongValue(JSONObject obj,
java.lang.String key,
long defaultValue)
Get a long from the JSON object or the defaultValue if it doesn't exist or isn't a long. |
static RESTException |
getRESTException(JSONValue val,
int statusCode,
java.lang.String url)
Get the RESTException containing the information in the specified JSON or null if the JSON object does not correspond to the NCAC exception format. |
static java.lang.String |
getStringValue(JSONObject obj,
java.lang.String key)
Get a string from the JSON object or null if it doesn't exist or isn't a string |
static java.lang.String |
getStringValue(JSONObject obj,
java.lang.String key,
java.lang.String defaultValue)
Get a string from the JSON object or defaultValue if it doesn't exist or isn't a string |
static java.lang.String |
getStringValueIgnoreCase(JSONObject obj,
java.lang.String key)
Get a string from the JSON object or null if it doesn't exist or isn't a string |
static java.lang.String |
getStringValueIgnoreCase(JSONObject obj,
java.lang.String key,
java.lang.String defaultValue)
Get a string from the JSON object or defaultValue if it doesn't exist or isn't a string |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String getStringValue(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static java.lang.String getStringValue(JSONObject obj, java.lang.String key, java.lang.String defaultValue)
obj
- the object with the valuekey
- the key for the objectdefaultValue
- the default value to return if the key could not be found
public static java.lang.String getStringValueIgnoreCase(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static java.lang.String getStringValueIgnoreCase(JSONObject obj, java.lang.String key, java.lang.String defaultValue)
obj
- the object with the valuekey
- the key for the objectdefaultValue
- the default value to return if the key could not be found
public static boolean getBooleanValue(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static boolean getBooleanValue(JSONObject obj, java.lang.String key, boolean defaultValue)
obj
- the object with the valuekey
- the key for the objectdefaultValue
- the default value if the key can not be found
public static JSONArray getJSONArray(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static int getIntValue(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static int getIntValue(JSONObject obj, java.lang.String key, int defaultValue)
obj
- the object with the valuekey
- the key for the objectdefaultValue
- the default value if the specified key isn't found.
public static double getDoubleValue(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static double getDoubleValue(JSONObject obj, java.lang.String key, double defaultValue)
obj
- the object with the valuekey
- the key for the objectdefaultValue
- the default value if the specified key isn't found.
public static long getLongValue(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static long getLongValue(JSONObject obj, java.lang.String key, long defaultValue)
obj
- the object with the valuekey
- the key for the objectdefaultValue
- the default value if the specified key isn't found.
public static JSONObject getJSONObject(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static java.util.Date getDateValue(JSONObject obj, java.lang.String key)
obj
- the object with the valuekey
- the key for the object
public static boolean containsKeyIgnoreCase(JSONObject obj, java.lang.String key)
obj
- the object containing the keykey
- the key to look for
public static JSONValue getIgnoreCase(JSONObject obj, java.lang.String key)
obj
- the object containing the valuekey
- the key of the value
public static RESTException getRESTException(JSONValue val, int statusCode, java.lang.String url)
val
- the JSON value containing the exceptionstatusCode
- the status code of the response that generated this dataurl
- the URL that was called to get this JSON
|
Spiffy UI Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |