Class 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 JSONArray
        func - 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 JSONObject
        func - the function to apply to primitive values
        Returns:
        the copy with the replaced values
        Throws:
        JSONException - if JSON operations fail