Package org.apache.sling.commons.json.io
Class JSONRenderer
java.lang.Object
org.apache.sling.commons.json.io.JSONRenderer
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleToString
(double d) Deprecated.Produce a string from a double.Deprecated.Make a string from the contents of this JSONArray.Deprecated.Produce a string from a Number.options()
Deprecated.Return an Options object with default valuesprettyPrint
(JSONArray ja, JSONRenderer.Options opt) Deprecated.Pretty-print a JSONArrayprettyPrint
(JSONObject jo, JSONRenderer.Options opt) Deprecated.Make a prettyprinted JSON text of this JSONObject.void
Deprecated.Quote the supplied string for JSON, to the supplied WriterDeprecated.Quote the supplied string for JSONvoid
Deprecated.Throw an exception if the object is an NaN or infinite number.Deprecated.Make a JSON text of the supplied JSONArray.toString
(JSONObject jo) Deprecated.Render the supplied JSONObject to a String, in the simplest possible way.valueToString
(Object value) Deprecated.Make a JSON text of an Object value.valueToString
(Object value, JSONRenderer.Options opt) Deprecated.Make a JSON String of an Object value, with rendering optionsDeprecated.Write the contents of the supplied JSONArray as JSON text to a writer.write
(Writer writer, JSONObject jo) Deprecated.Write the contents of the supplied JSONObject as JSON text to a writer.
-
Constructor Details
-
JSONRenderer
public JSONRenderer()Deprecated.
-
-
Method Details
-
options
Deprecated.Return an Options object with default values -
toString
Deprecated.Render the supplied JSONObject to a String, in the simplest possible way. -
toString
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
Deprecated.Quote the supplied string for JSON -
quote
Deprecated.Quote the supplied string for JSON, to the supplied Writer- Throws:
IOException
-
valueToString
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
Deprecated.Make a JSON String of an Object value, with rendering optionsWarning: 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
Deprecated.Produce a string from a Number.- Parameters:
n
- A Number- Returns:
- A String.
- Throws:
JSONException
- If n is a non-finite number.
-
prettyPrint
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
Deprecated.Pretty-print a JSONArray- Throws:
JSONException
-
testNumberValidity
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
Deprecated.Make a string from the contents of this JSONArray. Theseparator
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
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
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
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.
-