Package org.apache.sling.commons.json.io

# Class JSONRenderer

java.lang.Object
org.apache.sling.commons.json.io.JSONRenderer

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

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### JSONRenderer

public JSONRenderer()
Deprecated.

## Method Details

### options

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

### toString

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

### toString

public 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 String quote(String string)
Deprecated.
Quote the supplied string for JSON

### quote

public void quote(Writer w, String string) throws IOException
Deprecated.
Quote the supplied string for JSON, to the supplied Writer

Throws:
  `IOException`

### valueToString

public String valueToString(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 String valueToString(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 String numberToString(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 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.

### prettyPrint

public String prettyPrint(JSONArray ja, JSONRenderer.Options opt) throws JSONException
Deprecated.
Pretty-print a JSONArray

Throws:
  `JSONException`

### testNumberValidity

public void testNumberValidity(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 String join(JSONArray ja, 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 Writer write(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 Writer write(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 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.