Class CmsJsonUtil

java.lang.Object
org.opencms.util.CmsJsonUtil

public class CmsJsonUtil extends Object
Utility class for JSON-related functions.
  • Constructor Details

  • Method Details

    • mapJson

      public static Object mapJson(Object obj, Function<Object,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 JSONArray
      func - the function to apply to primitive values
      Returns:
      the copy with the replaced values
      Throws:
      JSONException - if JSON operations fail
    • mapJsonObject

      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 JSONObject
      func - the function to apply to primitive values
      Returns:
      the copy with the replaced values
      Throws:
      JSONException - if JSON operations fail