Class JSONRenderer


  • @Deprecated
    public class JSONRenderer
    extends java.lang.Object
    Deprecated.
    Various JSON-to-String primitives, used by other classes when outputting/formatting JSON. Streaming variants of some methods are provided. The existing code in this module is often not streaming, but we should write newer code using streams, as much as possible.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  JSONRenderer.Options
      Deprecated.
      Rendering options
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONRenderer()
      Deprecated.
       
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.String doubleToString​(double d)
      Deprecated.
      Produce a string from a double.
      java.lang.String join​(JSONArray ja, java.lang.String separator)
      Deprecated.
      Make a string from the contents of this JSONArray.
      java.lang.String numberToString​(java.lang.Number n)
      Deprecated.
      Produce a string from a Number.
      JSONRenderer.Options options()
      Deprecated.
      Return an Options object with default values
      java.lang.String prettyPrint​(JSONArray ja, JSONRenderer.Options opt)
      Deprecated.
      Pretty-print a JSONArray
      java.lang.String prettyPrint​(JSONObject jo, JSONRenderer.Options opt)
      Deprecated.
      Make a prettyprinted JSON text of this JSONObject.
      void quote​(java.io.Writer w, java.lang.String string)
      Deprecated.
      Quote the supplied string for JSON, to the supplied Writer
      java.lang.String quote​(java.lang.String string)
      Deprecated.
      Quote the supplied string for JSON
      void testNumberValidity​(java.lang.Object o)
      Deprecated.
      Throw an exception if the object is an NaN or infinite number.
      java.lang.String toString​(JSONArray ja)
      Deprecated.
      Make a JSON text of the supplied JSONArray.
      java.lang.String toString​(JSONObject jo)
      Deprecated.
      Render the supplied JSONObject to a String, in the simplest possible way.
      java.lang.String valueToString​(java.lang.Object value)
      Deprecated.
      Make a JSON text of an Object value.
      java.lang.String valueToString​(java.lang.Object value, JSONRenderer.Options opt)
      Deprecated.
      Make a JSON String of an Object value, with rendering options
      java.io.Writer write​(java.io.Writer writer, JSONArray ja)
      Deprecated.
      Write the contents of the supplied JSONArray as JSON text to a writer.
      java.io.Writer write​(java.io.Writer writer, JSONObject jo)
      Deprecated.
      Write the contents of the supplied JSONObject as JSON text to a writer.
      • Methods inherited from class java.lang.Object

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

      • JSONRenderer

        public JSONRenderer()
        Deprecated.
    • Method Detail

      • options

        public JSONRenderer.Options options()
        Deprecated.
        Return an Options object with default values
      • toString

        public java.lang.String toString​(JSONObject jo)
        Deprecated.
        Render the supplied JSONObject to a String, in the simplest possible way.
      • toString

        public java.lang.String toString​(JSONArray ja)
        Deprecated.
        Make a JSON text of the supplied JSONArray. For compactness, no unnecessary whitespace is added. If it is not possible to produce a syntactically correct JSON text then null will be returned instead. This could occur if the array contains an invalid number.

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

        Returns:
        a printable, displayable, transmittable representation of the array.
      • quote

        public java.lang.String quote​(java.lang.String string)
        Deprecated.
        Quote the supplied string for JSON
      • quote

        public void quote​(java.io.Writer w,
                          java.lang.String string)
                   throws java.io.IOException
        Deprecated.
        Quote the supplied string for JSON, to the supplied Writer
        Throws:
        java.io.IOException
      • valueToString

        public java.lang.String valueToString​(java.lang.Object value)
                                       throws JSONException
        Deprecated.
        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.

        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:
        JSONException - If the value is or contains an invalid number.
      • valueToString

        public java.lang.String valueToString​(java.lang.Object value,
                                              JSONRenderer.Options opt)
                                       throws JSONException
        Deprecated.
        Make a JSON String of an Object value, with rendering options

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

        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:
        JSONException - If the object contains an invalid number.
      • numberToString

        public java.lang.String numberToString​(java.lang.Number n)
                                        throws JSONException
        Deprecated.
        Produce a string from a Number.
        Parameters:
        n - A Number
        Returns:
        A String.
        Throws:
        JSONException - If n is a non-finite number.
      • prettyPrint

        public java.lang.String prettyPrint​(JSONObject jo,
                                            JSONRenderer.Options opt)
                                     throws JSONException
        Deprecated.
        Make a prettyprinted JSON text of this JSONObject.

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

        Returns:
        a printable, displayable, transmittable representation of the object, beginning with { (left brace) and ending with } (right brace).
        Throws:
        JSONException - If the object contains an invalid number.
      • testNumberValidity

        public void testNumberValidity​(java.lang.Object o)
                                throws JSONException
        Deprecated.
        Throw an exception if the object is an NaN or infinite number.
        Parameters:
        o - The object to test.
        Throws:
        JSONException - If o is a non-finite number.
      • join

        public java.lang.String join​(JSONArray ja,
                                     java.lang.String separator)
                              throws JSONException
        Deprecated.
        Make a string from the contents of this JSONArray. The separator string is inserted between each element. Warning: This method assumes that the data structure is acyclical.
        Parameters:
        separator - A string that will be inserted between the elements.
        Returns:
        a string.
        Throws:
        JSONException - If the array contains an invalid number.
      • write

        public java.io.Writer write​(java.io.Writer writer,
                                    JSONObject jo)
                             throws JSONException
        Deprecated.
        Write the contents of the supplied JSONObject as JSON text to a writer. For compactness, no whitespace is added.

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

        Returns:
        The writer.
        Throws:
        JSONException
      • write

        public java.io.Writer write​(java.io.Writer writer,
                                    JSONArray ja)
                             throws JSONException
        Deprecated.
        Write the contents of the supplied JSONArray as JSON text to a writer. For compactness, no whitespace is added.

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

        Returns:
        The writer.
        Throws:
        JSONException
      • doubleToString

        public java.lang.String doubleToString​(double d)
        Deprecated.
        Produce a string from a double. The string "null" will be returned if the number is not finite.
        Parameters:
        d - A double.
        Returns:
        A String.