Class JSONUtil

java.lang.Object
com.adobe.granite.xss.JSONUtil

@Deprecated public class JSONUtil extends 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 Details

    • KEY_SUFFIX_XSS

      public static final String KEY_SUFFIX_XSS
      Deprecated.
      Key suffix for XSS protected properties
      See Also:
  • Constructor Details

    • JSONUtil

      public JSONUtil()
      Deprecated.
  • Method Details

    • putProtected

      public static void putProtected(JSONObject object, String key, 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
      NullPointerException - If xss protection filter is null
    • putWithProtected

      public static void putWithProtected(JSONObject object, String key, 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
      NullPointerException - If xss protection filter is null
    • writeProtected

      public static void writeProtected(JSONWriter writer, String key, 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
      NullPointerException - If xss protection filter is null
    • writeProtected

      public static void writeProtected(JSONWriter writer, String key, 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.
      NullPointerException - If xss protection filter is null
    • writeWithProtected

      public static void writeWithProtected(JSONWriter writer, String key, 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
      NullPointerException - If xss protection filter is null
    • writeWithProtected

      public static void writeWithProtected(JSONWriter writer, String key, 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.
      NullPointerException - If xss protection filter is null