-
public class JSONUtils
-
-
Field Summary
Fields Modifier and Type Field Description private final StringEXTERNAL_USER_IDpublic final static JSONUtilsINSTANCE
-
Method Summary
Modifier and Type Method Description final JSONArraywrapInJsonArray(JSONObject jsonObject)Wrap the provided JSONObject as a JSONArray with one entry (the object). final JSONObjectbundleAsJSONObject(Bundle bundle)final BundlejsonStringToBundle(String data)final Map<String, String>newStringMapFromJSONObject(JSONObject jsonObject)final Set<String>newStringSetFromJSONArray(JSONArray jsonArray)final StringtoUnescapedEUIDString(JSONObject json)Returns the JSONObject as a String with the external user ID unescaped. final BooleancompareJSONArrays(JSONArray jsonArray1, JSONArray jsonArray2)Compare two JSONArrays too determine if they are equal or not final ObjectnormalizeType(Object object)final BooleanisValidJsonObject(Object value)Check if an object is JSON-serializable. final JSONObjectmapToJson(Map<String, Object> map)Recursively convert a JSON-serializable map into a JSON-compatible format, handling nested Maps and Lists appropriately. final ObjectconvertToJson(Object value)Recursively converts maps and lists into JSON-compatible objects, transforming maps with String keys into JSON objects, lists into JSON arrays, and leaving primitive values unchanged to support safe JSON serialization. final StringgetEXTERNAL_USER_ID()-
-
Method Detail
-
wrapInJsonArray
final JSONArray wrapInJsonArray(JSONObject jsonObject)
Wrap the provided JSONObject as a JSONArray with one entry (the object).
- Parameters:
jsonObject- The object that is to be wrapped within an array.
-
bundleAsJSONObject
final JSONObject bundleAsJSONObject(Bundle bundle)
-
jsonStringToBundle
final Bundle jsonStringToBundle(String data)
-
newStringMapFromJSONObject
final Map<String, String> newStringMapFromJSONObject(JSONObject jsonObject)
-
newStringSetFromJSONArray
final Set<String> newStringSetFromJSONArray(JSONArray jsonArray)
-
toUnescapedEUIDString
final String toUnescapedEUIDString(JSONObject json)
Returns the JSONObject as a String with the external user ID unescaped. Needed b/c the default JSONObject.toString() escapes (/) with (\/), which customers may not want.
-
compareJSONArrays
final Boolean compareJSONArrays(JSONArray jsonArray1, JSONArray jsonArray2)
Compare two JSONArrays too determine if they are equal or not
-
normalizeType
final Object normalizeType(Object object)
-
isValidJsonObject
final Boolean isValidJsonObject(Object value)
Check if an object is JSON-serializable. Recursively check each item if object is a map or a list.
-
mapToJson
final JSONObject mapToJson(Map<String, Object> map)
Recursively convert a JSON-serializable map into a JSON-compatible format, handling nested Maps and Lists appropriately.
-
convertToJson
final Object convertToJson(Object value)
Recursively converts maps and lists into JSON-compatible objects, transforming maps with String keys into JSON objects, lists into JSON arrays, and leaving primitive values unchanged to support safe JSON serialization.
-
getEXTERNAL_USER_ID
final String getEXTERNAL_USER_ID()
-
-
-
-