Package org.opencms.util
Class CmsJsonUtil
- java.lang.Object
-
- org.opencms.util.CmsJsonUtil
-
public class CmsJsonUtil extends java.lang.Object
Utility class for JSON-related functions.
-
-
Constructor Summary
Constructors Constructor Description CmsJsonUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
mapJson(java.lang.Object obj, java.util.function.Function<java.lang.Object,java.lang.Object> func)
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, java.util.function.Function<java.lang.Object,java.lang.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 Detail
-
CmsJsonUtil
public CmsJsonUtil()
-
-
Method Detail
-
mapJson
public static java.lang.Object mapJson(java.lang.Object obj, java.util.function.Function<java.lang.Object,java.lang.Object> func) throws JSONException
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, java.util.function.Function<java.lang.Object,java.lang.Object> func) throws JSONException
Recursively 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
-
-