Class JSONRenderer


  • public class JSONRenderer
    extends org.apache.sling.commons.json.io.JSONRenderer
    Extending Sling JSONObject to override the behaviour of toString.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.sling.commons.json.io.JSONRenderer

        org.apache.sling.commons.json.io.JSONRenderer.Options
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONRenderer()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String valueToString​(java.lang.Object value)
      Make a JSON text of an Object value.
      • Methods inherited from class org.apache.sling.commons.json.io.JSONRenderer

        doubleToString, join, numberToString, options, prettyPrint, prettyPrint, quote, quote, testNumberValidity, toString, toString, valueToString, write, write
      • Methods inherited from class java.lang.Object

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

      • JSONRenderer

        public JSONRenderer()
    • Method Detail

      • valueToString

        public java.lang.String valueToString​(java.lang.Object value)
                                       throws org.apache.sling.commons.json.JSONException
        Make a JSON text of an Object value. If the object has an value.toJSONString() method, then that method will be used to produce the JSON text. The method is required to produce a strictly conforming text. If the object does not contain a toJSONString method (which is the most common case), then a text will be produced by the rules.

        Warning: This method assumes that the data structure is acyclical.

        Overrides:
        valueToString in class org.apache.sling.commons.json.io.JSONRenderer
        Parameters:
        value - The value to be serialized.
        Returns:
        a printable, displayable, transmittable representation of the object, beginning with { (left brace) and ending with } (right brace).
        Throws:
        org.apache.sling.commons.json.JSONException - If the value is or contains an invalid number.