Package org.opencms.util
Class CmsJsonUtil
java.lang.Object
org.opencms.util.CmsJsonUtil
Utility class for JSON-related functions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
Recursively walks through a JSON structure and returns a copy of it, but transforms primitive values using the given function for the copy.static JSONObject
mapJsonObject
(JSONObject obj, Function<Object, Object> func) Recursively walks through a JSON object and returns a copy of it, but transforms primitive values using the given function for the copy.
-
Constructor Details
-
CmsJsonUtil
public CmsJsonUtil()
-
-
Method Details
-
mapJson
Recursively walks through a JSON structure and returns a copy of it, but transforms primitive values using the given function for the copy.- Parameters:
obj
- a JSONObject or JSONArrayfunc
- the function to apply to primitive values- Returns:
- the copy with the replaced values
- Throws:
JSONException
- if JSON operations fail
-
mapJsonObject
public static JSONObject mapJsonObject(JSONObject obj, Function<Object, Object> func) throws JSONExceptionRecursively walks through a JSON object and returns a copy of it, but transforms primitive values using the given function for the copy.- Parameters:
obj
- a JSONObjectfunc
- the function to apply to primitive values- Returns:
- the copy with the replaced values
- Throws:
JSONException
- if JSON operations fail
-