Class JSONUtil


  • @Deprecated
    public class JSONUtil
    extends java.lang.Object
    Deprecated.
    The org.apache.sling.commons.json API is deprecated.
    JSON utilities Support for handling xss protected values with JSON objects and JSON writers.
    Since:
    1.0.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String KEY_SUFFIX_XSS
      Deprecated.
      Key suffix for XSS protected properties
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONUtil()
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void putProtected​(JSONObject object, java.lang.String key, java.lang.String value, XSSFilter xss)
      Deprecated.
      Puts a xss protected value into a JSON object.
      static void putWithProtected​(JSONObject object, java.lang.String key, java.lang.String value, XSSFilter xss)
      Deprecated.
      Puts a value into a JSON object In addition, the xss protected value is put under the provided key appended by KEY_SUFFIX_XSS
      static void writeProtected​(JSONWriter writer, java.lang.String key, java.lang.String[] values, XSSFilter xss)
      Deprecated.
      Writes a xss protected value array into a JSON writer.
      static void writeProtected​(JSONWriter writer, java.lang.String key, java.lang.String value, XSSFilter xss)
      Deprecated.
      Writes a xss protected value into a JSON writer.
      static void writeWithProtected​(JSONWriter writer, java.lang.String key, java.lang.String[] values, XSSFilter xss)
      Deprecated.
      Writes a value array into a JSON write.
      static void writeWithProtected​(JSONWriter writer, java.lang.String key, java.lang.String value, XSSFilter xss)
      Deprecated.
      Writes a value into a JSON write In addition, the xss protected value is written with the provided key appended by KEY_SUFFIX_XSS
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • KEY_SUFFIX_XSS

        public static final java.lang.String KEY_SUFFIX_XSS
        Deprecated.
        Key suffix for XSS protected properties
        See Also:
        Constant Field Values
    • Constructor Detail

      • JSONUtil

        public JSONUtil()
        Deprecated.
    • Method Detail

      • putProtected

        public static void putProtected​(JSONObject object,
                                        java.lang.String key,
                                        java.lang.String value,
                                        XSSFilter xss)
                                 throws JSONException
        Deprecated.
        Puts a xss protected value into a JSON object. The value is put under the provided key.
        Parameters:
        object - JSON object
        key - Key to write
        value - Value to write
        xss - XSS protection filter
        Throws:
        JSONException - If value could not be put into the object
        java.lang.NullPointerException - If xss protection filter is null
      • putWithProtected

        public static void putWithProtected​(JSONObject object,
                                            java.lang.String key,
                                            java.lang.String value,
                                            XSSFilter xss)
                                     throws JSONException
        Deprecated.
        Puts a value into a JSON object In addition, the xss protected value is put under the provided key appended by KEY_SUFFIX_XSS
        Parameters:
        object - JSON object
        key - Key to write
        value - Value to write
        xss - XSS protection filter
        Throws:
        JSONException - If value could not be put into the object
        java.lang.NullPointerException - If xss protection filter is null
      • writeProtected

        public static void writeProtected​(JSONWriter writer,
                                          java.lang.String key,
                                          java.lang.String value,
                                          XSSFilter xss)
                                   throws JSONException
        Deprecated.
        Writes a xss protected value into a JSON writer. The value is written under the provided key.
        Parameters:
        writer - JSON writer
        key - Key to write
        value - Value to write
        xss - XSS protection filter
        Throws:
        JSONException - If value could not be written
        java.lang.NullPointerException - If xss protection filter is null
      • writeProtected

        public static void writeProtected​(JSONWriter writer,
                                          java.lang.String key,
                                          java.lang.String[] values,
                                          XSSFilter xss)
                                   throws JSONException
        Deprecated.
        Writes a xss protected value array into a JSON writer. The values are written under the provided key.
        Parameters:
        writer - The JSON writer.
        key - Key to use.
        values - The value arrays.
        xss - The XSS protection filter.
        Throws:
        JSONException - If an JSON specific error occurs.
        java.lang.NullPointerException - If xss protection filter is null
      • writeWithProtected

        public static void writeWithProtected​(JSONWriter writer,
                                              java.lang.String key,
                                              java.lang.String value,
                                              XSSFilter xss)
                                       throws JSONException
        Deprecated.
        Writes a value into a JSON write In addition, the xss protected value is written with the provided key appended by KEY_SUFFIX_XSS
        Parameters:
        writer - JSON writer
        key - Key to write
        value - Value to write
        xss - XSS protection filter
        Throws:
        JSONException - If value could not be written
        java.lang.NullPointerException - If xss protection filter is null
      • writeWithProtected

        public static void writeWithProtected​(JSONWriter writer,
                                              java.lang.String key,
                                              java.lang.String[] values,
                                              XSSFilter xss)
                                       throws JSONException
        Deprecated.
        Writes a value array into a JSON write. In addition, the xss protected values are written with the provided key appended by KEY_SUFFIX_XSS
        Parameters:
        writer - The JSON writer to use.
        key - The key to write.
        values - The value array.
        xss - The xss protection filter.
        Throws:
        JSONException - If a JSON specific error occurs.
        java.lang.NullPointerException - If xss protection filter is null