This commit is contained in:
drtshock
2014-01-20 12:22:09 -07:00
parent 0362170e9b
commit 2d6ac31c2c
19 changed files with 660 additions and 641 deletions
+200 -175
View File
@@ -34,47 +34,30 @@ import java.util.Iterator;
import java.util.Map;
/**
* A JSONArray is an ordered sequence of values. Its external text form is a
* string wrapped in square brackets with commas separating the values. The
* internal form is an object having <code>get</code> and <code>opt</code>
* methods for accessing the values by index, and <code>put</code> methods for
* adding or replacing values. The values can be any of these types:
* <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
* <code>Number</code>, <code>String</code>, or the
* <code>JSONObject.NULL object</code>.
* <p>
* The constructor can convert a JSON text into a Java object. The
* <code>toString</code> method converts to JSON text.
* <p>
* A <code>get</code> method returns a value if one can be found, and throws an
* exception if one cannot be found. An <code>opt</code> method returns a
* default value instead of throwing an exception, and so is useful for
* obtaining optional values.
* <p>
* The generic <code>get()</code> and <code>opt()</code> methods return an
* object which you can cast or query for type. There are also typed
* <code>get</code> and <code>opt</code> methods that do type checking and type
* coercion for you.
* <p>
* The texts produced by the <code>toString</code> methods strictly conform to
* JSON syntax rules. The constructors are more forgiving in the texts they will
* accept:
* <ul>
* <li>An extra <code>,</code>&nbsp;<small>(comma)</small> may appear just
* before the closing bracket.</li>
* <li>The <code>null</code> value will be inserted when there is <code>,</code>
* &nbsp;<small>(comma)</small> elision.</li>
* <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single
* quote)</small>.</li>
* <li>Strings do not need to be quoted at all if they do not begin with a quote
* or single quote, and if they do not contain leading or trailing spaces, and
* if they do not contain any of these characters:
* <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and
* if they are not the reserved words <code>true</code>, <code>false</code>, or
* <code>null</code>.</li>
* <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as
* well as by <code>,</code> <small>(comma)</small>.</li>
* </ul>
* A JSONArray is an ordered sequence of values. Its external text form is a string wrapped in square brackets with
* commas separating the values. The internal form is an object having <code>get</code> and <code>opt</code> methods for
* accessing the values by index, and <code>put</code> methods for adding or replacing values. The values can be any of
* these types: <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
* <code>String</code>, or the <code>JSONObject.NULL object</code>.
* <p/>
* The constructor can convert a JSON text into a Java object. The <code>toString</code> method converts to JSON text.
* <p/>
* A <code>get</code> method returns a value if one can be found, and throws an exception if one cannot be found. An
* <code>opt</code> method returns a default value instead of throwing an exception, and so is useful for obtaining
* optional values.
* <p/>
* The generic <code>get()</code> and <code>opt()</code> methods return an object which you can cast or query for type.
* There are also typed <code>get</code> and <code>opt</code> methods that do type checking and type coercion for you.
* <p/>
* The texts produced by the <code>toString</code> methods strictly conform to JSON syntax rules. The constructors are
* more forgiving in the texts they will accept: <ul> <li>An extra <code>,</code>&nbsp;<small>(comma)</small> may appear
* just before the closing bracket.</li> <li>The <code>null</code> value will be inserted when there is <code>,</code>
* &nbsp;<small>(comma)</small> elision.</li> <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single
* quote)</small>.</li> <li>Strings do not need to be quoted at all if they do not begin with a quote or single quote,
* and if they do not contain leading or trailing spaces, and if they do not contain any of these characters: <code>{ }
* [ ] / \ : , = ; #</code> and if they do not look like numbers and if they are not the reserved words
* <code>true</code>, <code>false</code>, or <code>null</code>.</li> <li>Values can be separated by <code>;</code>
* <small>(semicolon)</small> as well as by <code>,</code> <small>(comma)</small>.</li> </ul>
*
* @author JSON.org
* @version 2012-11-13
@@ -95,7 +78,9 @@ public class JSONArray {
/**
* Construct a JSONArray from a JSONTokener.
*
* @param x A JSONTokener
*
* @throws JSONException If there is a syntax error.
*/
public JSONArray(JSONTokener x) throws JSONException {
@@ -132,10 +117,11 @@ public class JSONArray {
/**
* Construct a JSONArray from a source JSON text.
* @param source A string that begins with
* <code>[</code>&nbsp;<small>(left bracket)</small>
* and ends with <code>]</code>&nbsp;<small>(right bracket)</small>.
* @throws JSONException If there is a syntax error.
*
* @param source A string that begins with <code>[</code>&nbsp;<small>(left bracket)</small> and ends with
* <code>]</code>&nbsp;<small>(right bracket)</small>.
*
* @throws JSONException If there is a syntax error.
*/
public JSONArray(String source) throws JSONException {
this(new JSONTokener(source));
@@ -143,7 +129,8 @@ public class JSONArray {
/**
* Construct a JSONArray from a Collection.
* @param collection A Collection.
*
* @param collection A Collection.
*/
public JSONArray(Collection<?> collection) {
this.myArrayList = new ArrayList<Object>();
@@ -157,6 +144,7 @@ public class JSONArray {
/**
* Construct a JSONArray from an array
*
* @throws JSONException If not an array.
*/
public JSONArray(Object array) throws JSONException {
@@ -174,9 +162,11 @@ public class JSONArray {
/**
* Get the object value associated with an index.
* @param index
* The index must be between 0 and length() - 1.
*
* @param index The index must be between 0 and length() - 1.
*
* @return An object value.
*
* @throws JSONException If there is no value for the index.
*/
public Object get(int index) throws JSONException {
@@ -188,13 +178,13 @@ public class JSONArray {
}
/**
* Get the boolean value associated with an index.
* The string values "true" and "false" are converted to boolean.
* Get the boolean value associated with an index. The string values "true" and "false" are converted to boolean.
*
* @param index The index must be between 0 and length() - 1.
*
* @return The truth.
* @throws JSONException If there is no value for the index or if the
* value is not convertible to boolean.
*
* @throws JSONException If there is no value for the index or if the value is not convertible to boolean.
*/
public boolean getBoolean(int index) throws JSONException {
Object object = this.get(index);
@@ -214,9 +204,10 @@ public class JSONArray {
* Get the double value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
*
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
*
* @throws JSONException If the key is not found or if the value cannot be converted to a number.
*/
public double getDouble(int index) throws JSONException {
Object object = this.get(index);
@@ -234,7 +225,9 @@ public class JSONArray {
* Get the int value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
*
* @return The value.
*
* @throws JSONException If the key is not found or if the value is not a number.
*/
public int getInt(int index) throws JSONException {
@@ -251,10 +244,12 @@ public class JSONArray {
/**
* Get the JSONArray associated with an index.
*
* @param index The index must be between 0 and length() - 1.
*
* @return A JSONArray value.
* @throws JSONException If there is no value for the index. or if the
* value is not a JSONArray
*
* @throws JSONException If there is no value for the index. or if the value is not a JSONArray
*/
public JSONArray getJSONArray(int index) throws JSONException {
Object object = this.get(index);
@@ -267,10 +262,12 @@ public class JSONArray {
/**
* Get the JSONObject associated with an index.
*
* @param index subscript
*
* @return A JSONObject value.
* @throws JSONException If there is no value for the index or if the
* value is not a JSONObject
*
* @throws JSONException If there is no value for the index or if the value is not a JSONObject
*/
public JSONObject getJSONObject(int index) throws JSONException {
Object object = this.get(index);
@@ -285,9 +282,10 @@ public class JSONArray {
* Get the long value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
*
* @return The value.
* @throws JSONException If the key is not found or if the value cannot
* be converted to a number.
*
* @throws JSONException If the key is not found or if the value cannot be converted to a number.
*/
public long getLong(int index) throws JSONException {
Object object = this.get(index);
@@ -303,8 +301,11 @@ public class JSONArray {
/**
* Get the string associated with an index.
*
* @param index The index must be between 0 and length() - 1.
*
* @return A string value.
*
* @throws JSONException If there is no string value for the index.
*/
public String getString(int index) throws JSONException {
@@ -317,7 +318,9 @@ public class JSONArray {
/**
* Determine if the value is null.
*
* @param index The index must be between 0 and length() - 1.
*
* @return true if the value at the index is null, or if there is no value.
*/
public boolean isNull(int index) {
@@ -325,11 +328,13 @@ public class JSONArray {
}
/**
* Make a string from the contents of this JSONArray. The
* <code>separator</code> string is inserted between each element.
* Warning: This method assumes that the data structure is acyclical.
* Make a string from the contents of this JSONArray. The <code>separator</code> string is inserted between each
* element. Warning: This method assumes that the data structure is acyclical.
*
* @param separator A string that will be inserted between the elements.
*
* @return a string.
*
* @throws JSONException If the array contains an invalid number.
*/
public String join(String separator) throws JSONException {
@@ -356,9 +361,10 @@ public class JSONArray {
/**
* Get the optional object value associated with an index.
*
* @param index The index must be between 0 and length() - 1.
* @return An object value, or null if there is no
* object at that index.
*
* @return An object value, or null if there is no object at that index.
*/
public Object opt(int index) {
return (index < 0 || index >= this.length())
@@ -367,11 +373,11 @@ public class JSONArray {
}
/**
* Get the optional boolean value associated with an index.
* It returns false if there is no value at that index,
* or if the value is not Boolean.TRUE or the String "true".
* Get the optional boolean value associated with an index. It returns false if there is no value at that index, or
* if the value is not Boolean.TRUE or the String "true".
*
* @param index The index must be between 0 and length() - 1.
*
* @return The truth.
*/
public boolean optBoolean(int index) {
@@ -379,12 +385,12 @@ public class JSONArray {
}
/**
* Get the optional boolean value associated with an index.
* It returns the defaultValue if there is no value at that index or if
* it is not a Boolean or the String "true" or "false" (case insensitive).
* Get the optional boolean value associated with an index. It returns the defaultValue if there is no value at that
* index or if it is not a Boolean or the String "true" or "false" (case insensitive).
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue A boolean default.
* @param defaultValue A boolean default.
*
* @return The truth.
*/
public boolean optBoolean(int index, boolean defaultValue) {
@@ -396,11 +402,11 @@ public class JSONArray {
}
/**
* Get the optional double value associated with an index.
* NaN is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
* Get the optional double value associated with an index. NaN is returned if there is no value for the index, or if
* the value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
*
* @return The value.
*/
public double optDouble(int index) {
@@ -408,12 +414,12 @@ public class JSONArray {
}
/**
* Get the optional double value associated with an index.
* The defaultValue is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
* Get the optional double value associated with an index. The defaultValue is returned if there is no value for the
* index, or if the value is not a number and cannot be converted to a number.
*
* @param index subscript
* @param defaultValue The default value.
* @param defaultValue The default value.
*
* @return The value.
*/
public double optDouble(int index, double defaultValue) {
@@ -425,11 +431,11 @@ public class JSONArray {
}
/**
* Get the optional int value associated with an index.
* Zero is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
* Get the optional int value associated with an index. Zero is returned if there is no value for the index, or if
* the value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
*
* @return The value.
*/
public int optInt(int index) {
@@ -437,11 +443,12 @@ public class JSONArray {
}
/**
* Get the optional int value associated with an index.
* The defaultValue is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
* Get the optional int value associated with an index. The defaultValue is returned if there is no value for the
* index, or if the value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @param defaultValue The default value.
*
* @return The value.
*/
public int optInt(int index, int defaultValue) {
@@ -454,9 +461,10 @@ public class JSONArray {
/**
* Get the optional JSONArray associated with an index.
*
* @param index subscript
* @return A JSONArray value, or null if the index has no value,
* or if the value is not a JSONArray.
*
* @return A JSONArray value, or null if the index has no value, or if the value is not a JSONArray.
*/
public JSONArray optJSONArray(int index) {
Object o = this.opt(index);
@@ -464,11 +472,11 @@ public class JSONArray {
}
/**
* Get the optional JSONObject associated with an index.
* Null is returned if the key is not found, or null if the index has
* no value, or if the value is not a JSONObject.
* Get the optional JSONObject associated with an index. Null is returned if the key is not found, or null if the
* index has no value, or if the value is not a JSONObject.
*
* @param index The index must be between 0 and length() - 1.
*
* @return A JSONObject value.
*/
public JSONObject optJSONObject(int index) {
@@ -477,11 +485,11 @@ public class JSONArray {
}
/**
* Get the optional long value associated with an index.
* Zero is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
* Get the optional long value associated with an index. Zero is returned if there is no value for the index, or if
* the value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
*
* @return The value.
*/
public long optLong(int index) {
@@ -489,11 +497,12 @@ public class JSONArray {
}
/**
* Get the optional long value associated with an index.
* The defaultValue is returned if there is no value for the index,
* or if the value is not a number and cannot be converted to a number.
* Get the optional long value associated with an index. The defaultValue is returned if there is no value for the
* index, or if the value is not a number and cannot be converted to a number.
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @param defaultValue The default value.
*
* @return The value.
*/
public long optLong(int index, long defaultValue) {
@@ -505,11 +514,11 @@ public class JSONArray {
}
/**
* Get the optional string value associated with an index. It returns an
* empty string if there is no value at that index. If the value
* is not a string and is not null, then it is coverted to a string.
* Get the optional string value associated with an index. It returns an empty string if there is no value at that
* index. If the value is not a string and is not null, then it is coverted to a string.
*
* @param index The index must be between 0 and length() - 1.
*
* @return A String value.
*/
public String optString(int index) {
@@ -517,11 +526,11 @@ public class JSONArray {
}
/**
* Get the optional string associated with an index.
* The defaultValue is returned if the key is not found.
* Get the optional string associated with an index. The defaultValue is returned if the key is not found.
*
* @param index The index must be between 0 and length() - 1.
* @param defaultValue The default value.
* @param defaultValue The default value.
*
* @return A String value.
*/
public String optString(int index, String defaultValue) {
@@ -535,6 +544,7 @@ public class JSONArray {
* Append a boolean value. This increases the array's length by one.
*
* @param value A boolean value.
*
* @return this.
*/
public JSONArray put(boolean value) {
@@ -543,9 +553,10 @@ public class JSONArray {
}
/**
* Put a value in the JSONArray, where the value will be a
* JSONArray which is produced from a Collection.
* Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection.
*
* @param value A Collection value.
*
* @return this.
*/
public JSONArray put(Collection<?> value) {
@@ -557,8 +568,10 @@ public class JSONArray {
* Append a double value. This increases the array's length by one.
*
* @param value A double value.
* @throws JSONException if the value is not finite.
*
* @return this.
*
* @throws JSONException if the value is not finite.
*/
public JSONArray put(double value) throws JSONException {
Double d = new Double(value);
@@ -571,6 +584,7 @@ public class JSONArray {
* Append an int value. This increases the array's length by one.
*
* @param value An int value.
*
* @return this.
*/
public JSONArray put(int value) {
@@ -582,6 +596,7 @@ public class JSONArray {
* Append an long value. This increases the array's length by one.
*
* @param value A long value.
*
* @return this.
*/
public JSONArray put(long value) {
@@ -590,9 +605,10 @@ public class JSONArray {
}
/**
* Put a value in the JSONArray, where the value will be a
* JSONObject which is produced from a Map.
* Put a value in the JSONArray, where the value will be a JSONObject which is produced from a Map.
*
* @param value A Map value.
*
* @return this.
*/
public JSONArray put(Map<?, ?> value) {
@@ -602,9 +618,10 @@ public class JSONArray {
/**
* Append an object value. This increases the array's length by one.
* @param value An object value. The value should be a
* Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
* JSONObject.NULL object.
*
* @param value An object value. The value should be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or
* String, or the JSONObject.NULL object.
*
* @return this.
*/
public JSONArray put(Object value) {
@@ -613,12 +630,14 @@ public class JSONArray {
}
/**
* Put or replace a boolean value in the JSONArray. If the index is greater
* than the length of the JSONArray, then null elements will be added as
* necessary to pad it out.
* Put or replace a boolean value in the JSONArray. If the index is greater than the length of the JSONArray, then
* null elements will be added as necessary to pad it out.
*
* @param index The subscript.
* @param value A boolean value.
*
* @return this.
*
* @throws JSONException If the index is negative.
*/
public JSONArray put(int index, boolean value) throws JSONException {
@@ -627,13 +646,14 @@ public class JSONArray {
}
/**
* Put a value in the JSONArray, where the value will be a
* JSONArray which is produced from a Collection.
* Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection.
*
* @param index The subscript.
* @param value A Collection value.
*
* @return this.
* @throws JSONException If the index is negative or if the value is
* not finite.
*
* @throws JSONException If the index is negative or if the value is not finite.
*/
public JSONArray put(int index, Collection<?> value) throws JSONException {
this.put(index, new JSONArray(value));
@@ -641,14 +661,15 @@ public class JSONArray {
}
/**
* Put or replace a double value. If the index is greater than the length of
* the JSONArray, then null elements will be added as necessary to pad
* it out.
* Put or replace a double value. If the index is greater than the length of the JSONArray, then null elements will
* be added as necessary to pad it out.
*
* @param index The subscript.
* @param value A double value.
*
* @return this.
* @throws JSONException If the index is negative or if the value is
* not finite.
*
* @throws JSONException If the index is negative or if the value is not finite.
*/
public JSONArray put(int index, double value) throws JSONException {
this.put(index, new Double(value));
@@ -656,12 +677,14 @@ public class JSONArray {
}
/**
* Put or replace an int value. If the index is greater than the length of
* the JSONArray, then null elements will be added as necessary to pad
* it out.
* Put or replace an int value. If the index is greater than the length of the JSONArray, then null elements will be
* added as necessary to pad it out.
*
* @param index The subscript.
* @param value An int value.
*
* @return this.
*
* @throws JSONException If the index is negative.
*/
public JSONArray put(int index, int value) throws JSONException {
@@ -670,12 +693,14 @@ public class JSONArray {
}
/**
* Put or replace a long value. If the index is greater than the length of
* the JSONArray, then null elements will be added as necessary to pad
* it out.
* Put or replace a long value. If the index is greater than the length of the JSONArray, then null elements will be
* added as necessary to pad it out.
*
* @param index The subscript.
* @param value A long value.
*
* @return this.
*
* @throws JSONException If the index is negative.
*/
public JSONArray put(int index, long value) throws JSONException {
@@ -684,13 +709,14 @@ public class JSONArray {
}
/**
* Put a value in the JSONArray, where the value will be a
* JSONObject that is produced from a Map.
* Put a value in the JSONArray, where the value will be a JSONObject that is produced from a Map.
*
* @param index The subscript.
* @param value The Map value.
*
* @return this.
* @throws JSONException If the index is negative or if the the value is
* an invalid number.
*
* @throws JSONException If the index is negative or if the the value is an invalid number.
*/
public JSONArray put(int index, Map<?, ?> value) throws JSONException {
this.put(index, new JSONObject(value));
@@ -698,16 +724,16 @@ public class JSONArray {
}
/**
* Put or replace an object value in the JSONArray. If the index is greater
* than the length of the JSONArray, then null elements will be added as
* necessary to pad it out.
* Put or replace an object value in the JSONArray. If the index is greater than the length of the JSONArray, then
* null elements will be added as necessary to pad it out.
*
* @param index The subscript.
* @param value The value to put into the array. The value should be a
* Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
* JSONObject.NULL object.
* @param value The value to put into the array. The value should be a Boolean, Double, Integer, JSONArray,
* JSONObject, Long, or String, or the JSONObject.NULL object.
*
* @return this.
* @throws JSONException If the index is negative or if the the value is
* an invalid number.
*
* @throws JSONException If the index is negative or if the the value is an invalid number.
*/
public JSONArray put(int index, Object value) throws JSONException {
JSONObject.testValidity(value);
@@ -727,9 +753,10 @@ public class JSONArray {
/**
* Remove an index and close the hole.
*
* @param index The index of the element to be removed.
* @return The value that was associated with the index,
* or null if there was no value.
*
* @return The value that was associated with the index, or null if there was no value.
*/
public Object remove(int index) {
Object o = this.opt(index);
@@ -738,12 +765,12 @@ public class JSONArray {
}
/**
* Produce a JSONObject by combining a JSONArray of names with the values
* of this JSONArray.
* @param names A JSONArray containing a list of key strings. These will be
* paired with the values.
* @return A JSONObject, or null if there are no names or if this JSONArray
* has no values.
* Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray.
*
* @param names A JSONArray containing a list of key strings. These will be paired with the values.
*
* @return A JSONObject, or null if there are no names or if this JSONArray has no values.
*
* @throws JSONException If any of the names are null.
*/
public JSONObject toJSONObject(JSONArray names) throws JSONException {
@@ -758,15 +785,13 @@ public class JSONArray {
}
/**
* Make a JSON text of this 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.
* <p>
* Make a JSON text of this 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.
* <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @return a printable, displayable, transmittable
* representation of the array.
* @return a printable, displayable, transmittable representation of the array.
*/
public String toString() {
try {
@@ -777,14 +802,15 @@ public class JSONArray {
}
/**
* Make a prettyprinted JSON text of this JSONArray.
* Warning: This method assumes that the data structure is acyclical.
* @param indentFactor The number of spaces to add to each level of
* indentation.
* @return a printable, displayable, transmittable
* representation of the object, beginning
* with <code>[</code>&nbsp;<small>(left bracket)</small> and ending
* with <code>]</code>&nbsp;<small>(right bracket)</small>.
* Make a prettyprinted JSON text of this JSONArray. Warning: This method assumes that the data structure is
* acyclical.
*
* @param indentFactor The number of spaces to add to each level of indentation.
*
* @return a printable, displayable, transmittable representation of the object, beginning with
* <code>[</code>&nbsp;<small>(left bracket)</small> and ending with <code>]</code>&nbsp;<small>(right
* bracket)</small>.
*
* @throws JSONException
*/
public String toString(int indentFactor) throws JSONException {
@@ -795,12 +821,12 @@ public class JSONArray {
}
/**
* Write the contents of the JSONArray as JSON text to a writer. For
* compactness, no whitespace is added.
* <p>
* Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added.
* <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @return The writer.
*
* @throws JSONException
*/
public Writer write(Writer writer) throws JSONException {
@@ -808,16 +834,15 @@ public class JSONArray {
}
/**
* Write the contents of the JSONArray as JSON text to a writer. For
* compactness, no whitespace is added.
* <p>
* Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added.
* <p/>
* Warning: This method assumes that the data structure is acyclical.
*
* @param indentFactor
* The number of spaces to add to each level of indentation.
* @param indent
* The indention of the top level.
* @param indentFactor The number of spaces to add to each level of indentation.
* @param indent The indention of the top level.
*
* @return The writer.
*
* @throws JSONException
*/
Writer write(Writer writer, int indentFactor, int indent)