Package com.openfin.desktop
Class JsonUtils
java.lang.Object
com.openfin.desktop.JsonUtils
public class JsonUtils
extends java.lang.Object
Helper methods for retrieving data from JSONObject
-
Constructor Summary
Constructors Constructor Description JsonUtils()
-
Method Summary
Modifier and Type Method Description static java.lang.Boolean
getBooleanValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Boolean defaultValue)
Retrieve an Boolean value from a JSONObjectstatic java.lang.Double
getDoubleValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Double defaultValue)
Retrieve an Double value from a JSONObjectstatic java.lang.Integer
getIntegerValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Integer defaultValue)
Retrieve an Integer value from a JSONObjectstatic org.json.JSONArray
getJsonArray(org.json.JSONObject jsonObject, java.lang.String property, org.json.JSONArray defaultValue)
Retrieve an JSONArray value from a JSONObjectstatic org.json.JSONObject
getJsonValue(org.json.JSONObject jsonObject, java.lang.String property, org.json.JSONObject defaultValue)
Retrieve an JSONObject value from a JSONObjectstatic java.lang.String
getStringValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.String defaultValue)
Retrieve a string value from a JSONObjectstatic void
updateValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Boolean value)
Update a Boolean value in an JSONOjectstatic void
updateValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Double value)
Update a Double value in an JSONOjectstatic void
updateValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Integer value)
Update a Integer value in an JSONOjectstatic void
updateValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.String value)
Update a String value in an JSONOjectstatic void
updateValue(org.json.JSONObject jsonObject, java.lang.String property, org.json.JSONArray value)
Update a JSONArray value in an JSONOjectstatic void
updateValue(org.json.JSONObject jsonObject, java.lang.String property, org.json.JSONObject value)
Update a JSONObject value in an JSONOject
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
getStringValue
public static java.lang.String getStringValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.String defaultValue)Retrieve a string value from a JSONObject- Parameters:
jsonObject
- JSONObject to get value fromproperty
- Property name of the valuedefaultValue
- Default value if the property does not exist- Returns:
- the String value
-
updateValue
public static void updateValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.String value) throws org.json.JSONExceptionUpdate a String value in an JSONOject- Parameters:
jsonObject
- JSONObject to updateproperty
- Name of the propertyvalue
- New value- Throws:
org.json.JSONException
- if update fails
-
getIntegerValue
public static java.lang.Integer getIntegerValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Integer defaultValue)Retrieve an Integer value from a JSONObject- Parameters:
jsonObject
- JSONObject to get value fromproperty
- Property name of the valuedefaultValue
- Default value if the property does not exist- Returns:
- the Integer value
-
updateValue
public static void updateValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Integer value) throws org.json.JSONExceptionUpdate a Integer value in an JSONOject- Parameters:
jsonObject
- JSONObject to updateproperty
- Name of the propertyvalue
- New value- Throws:
org.json.JSONException
- if update fails
-
getDoubleValue
public static java.lang.Double getDoubleValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Double defaultValue)Retrieve an Double value from a JSONObject- Parameters:
jsonObject
- JSONObject to get value fromproperty
- Property name of the valuedefaultValue
- Default value if the property does not exist- Returns:
- the Integer value
-
updateValue
public static void updateValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Double value) throws org.json.JSONExceptionUpdate a Double value in an JSONOject- Parameters:
jsonObject
- JSONObject to updateproperty
- Name of the propertyvalue
- New value- Throws:
org.json.JSONException
- if update fails
-
getBooleanValue
public static java.lang.Boolean getBooleanValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Boolean defaultValue)Retrieve an Boolean value from a JSONObject- Parameters:
jsonObject
- JSONObject to get value fromproperty
- Property name of the valuedefaultValue
- Default value if the property does not exist- Returns:
- the Integer value
-
updateValue
public static void updateValue(org.json.JSONObject jsonObject, java.lang.String property, java.lang.Boolean value) throws org.json.JSONExceptionUpdate a Boolean value in an JSONOject- Parameters:
jsonObject
- JSONObject to updateproperty
- Name of the propertyvalue
- New value- Throws:
org.json.JSONException
- if update fails
-
getJsonValue
public static org.json.JSONObject getJsonValue(org.json.JSONObject jsonObject, java.lang.String property, org.json.JSONObject defaultValue)Retrieve an JSONObject value from a JSONObject- Parameters:
jsonObject
- JSONObject to get value fromproperty
- Property name of the valuedefaultValue
- Default value if the property does not exist- Returns:
- the Integer value
-
updateValue
public static void updateValue(org.json.JSONObject jsonObject, java.lang.String property, org.json.JSONObject value) throws org.json.JSONExceptionUpdate a JSONObject value in an JSONOject- Parameters:
jsonObject
- to updateproperty
- Name of the propertyvalue
- New value- Throws:
org.json.JSONException
- if update fails
-
getJsonArray
public static org.json.JSONArray getJsonArray(org.json.JSONObject jsonObject, java.lang.String property, org.json.JSONArray defaultValue)Retrieve an JSONArray value from a JSONObject- Parameters:
jsonObject
- JSONObject to get value fromproperty
- Property name of the valuedefaultValue
- Default value if the property does not exist- Returns:
- the Integer value
-
updateValue
public static void updateValue(org.json.JSONObject jsonObject, java.lang.String property, org.json.JSONArray value) throws org.json.JSONExceptionUpdate a JSONArray value in an JSONOject- Parameters:
jsonObject
- to updateproperty
- Name of the propertyvalue
- New value- Throws:
org.json.JSONException
- if update fails
-