public final class JSONArray extends java.lang.Object implements JSON, java.util.List<java.lang.Object>, java.lang.Comparable
get
and opt
methods for accessing the values by index, and element
methods
for adding or replacing values. The values can be any of these types:
Boolean
, JSONArray
, JSONObject
,
Number
, String
, or the
JSONNull object
.
The constructor can convert a JSON text into a Java object. The
toString
method converts to JSON text.
A get
method returns a value if one can be found, and throws
an exception if one cannot be found. An opt
method returns a
default value instead of throwing an exception, and so is useful for
obtaining optional values.
The generic get()
and opt()
methods return an
object which you can cast or query for type. There are also typed
get
and opt
methods that do type checking and
type coersion for you.
The texts produced by the toString
methods strictly conform to
JSON syntax rules. The constructors are more forgiving in the texts they will
accept:
,
(comma) may appear just
before the closing bracket.null
value will be inserted when there is
,
(comma) elision.'
(single quote).{ } [ ] / \ : , = ; #
and if they do not look like numbers and
if they are not the reserved words true
, false
,
or null
.;
(semicolon)
as well as by ,
(comma).0-
(octal) or
0x-
(hex) prefix.Constructor and Description |
---|
JSONArray()
Construct an empty JSONArray.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
_processValue(java.lang.Object value,
JsonConfig jsonConfig) |
void |
add(int index,
java.lang.Object value) |
void |
add(int index,
java.lang.Object value,
JsonConfig jsonConfig) |
boolean |
add(java.lang.Object value) |
boolean |
add(java.lang.Object value,
JsonConfig jsonConfig) |
boolean |
addAll(java.util.Collection collection) |
boolean |
addAll(java.util.Collection collection,
JsonConfig jsonConfig) |
boolean |
addAll(int index,
java.util.Collection collection) |
boolean |
addAll(int index,
java.util.Collection collection,
JsonConfig jsonConfig) |
protected static boolean |
addInstance(java.lang.Object instance)
Adds a reference for cycle detection check.
|
protected JSONArray |
addString(java.lang.String str)
Adds a String without performing any conversion on it.
|
void |
clear() |
int |
compareTo(java.lang.Object obj) |
boolean |
contains(java.lang.Object o) |
boolean |
contains(java.lang.Object o,
JsonConfig jsonConfig) |
boolean |
containsAll(java.util.Collection collection) |
boolean |
containsAll(java.util.Collection collection,
JsonConfig jsonConfig) |
JSONArray |
discard(int index)
Remove an element, if present.
|
JSONArray |
discard(java.lang.Object o)
Remove an element, if present.
|
JSONArray |
element(boolean value)
Append a boolean value.
|
JSONArray |
element(java.util.Collection value)
Append a value in the JSONArray, where the value will be a JSONArray which
is produced from a Collection.
|
JSONArray |
element(java.util.Collection value,
JsonConfig jsonConfig)
Append a value in the JSONArray, where the value will be a JSONArray which
is produced from a Collection.
|
JSONArray |
element(double value)
Append a double value.
|
JSONArray |
element(int value)
Append an int value.
|
JSONArray |
element(int index,
boolean value)
Put or replace a boolean value in the JSONArray.
|
JSONArray |
element(int index,
java.util.Collection value)
Put a value in the JSONArray, where the value will be a JSONArray which is
produced from a Collection.
|
JSONArray |
element(int index,
java.util.Collection value,
JsonConfig jsonConfig)
Put a value in the JSONArray, where the value will be a JSONArray which is
produced from a Collection.
|
JSONArray |
element(int index,
double value)
Put or replace a double value.
|
JSONArray |
element(int index,
int value)
Put or replace an int value.
|
JSONArray |
element(int index,
long value)
Put or replace a long value.
|
JSONArray |
element(int index,
java.util.Map value)
Put a value in the JSONArray, where the value will be a JSONObject which
is produced from a Map.
|
JSONArray |
element(int index,
java.util.Map value,
JsonConfig jsonConfig)
Put a value in the JSONArray, where the value will be a JSONObject which
is produced from a Map.
|
JSONArray |
element(int index,
java.lang.Object value)
Put or replace an object value in the JSONArray.
|
JSONArray |
element(int index,
java.lang.Object value,
JsonConfig jsonConfig)
Put or replace an object value in the JSONArray.
|
JSONArray |
element(int index,
java.lang.String value)
Put or replace a String value in the JSONArray.
|
JSONArray |
element(int index,
java.lang.String value,
JsonConfig jsonConfig)
Put or replace a String value in the JSONArray.
|
JSONArray |
element(JSONNull value)
Append an JSON value.
|
JSONArray |
element(JSONObject value)
Append an JSON value.
|
JSONArray |
element(long value)
Append an long value.
|
JSONArray |
element(java.util.Map value)
Put a value in the JSONArray, where the value will be a JSONObject which
is produced from a Map.
|
JSONArray |
element(java.util.Map value,
JsonConfig jsonConfig)
Put a value in the JSONArray, where the value will be a JSONObject which
is produced from a Map.
|
JSONArray |
element(java.lang.Object value)
Append an object value.
|
JSONArray |
element(java.lang.Object value,
JsonConfig jsonConfig)
Append an object value.
|
JSONArray |
element(java.lang.String value)
Append a String value.
|
JSONArray |
element(java.lang.String value,
JsonConfig jsonConfig)
Append a String value.
|
boolean |
equals(java.lang.Object obj) |
protected static void |
fireArrayEndEvent(JsonConfig jsonConfig)
Fires an end of array event.
|
protected static void |
fireArrayStartEvent(JsonConfig jsonConfig)
Fires a start of array event.
|
protected static void |
fireElementAddedEvent(int index,
java.lang.Object element,
JsonConfig jsonConfig)
Fires an element added event.
|
protected static void |
fireErrorEvent(JSONException jsone,
JsonConfig jsonConfig)
Fires an error event.
|
protected static void |
fireObjectEndEvent(JsonConfig jsonConfig)
Fires an end of object event.
|
protected static void |
fireObjectStartEvent(JsonConfig jsonConfig)
Fires a start of object event.
|
protected static void |
firePropertySetEvent(java.lang.String key,
java.lang.Object value,
boolean accumulated,
JsonConfig jsonConfig)
Fires a property set event.
|
protected static void |
fireWarnEvent(java.lang.String warning,
JsonConfig jsonConfig)
Fires a warning event.
|
static JSONArray |
fromObject(java.lang.Object object)
Creates a JSONArray.
Inspects the object type to call the correct JSONArray factory method. |
static JSONArray |
fromObject(java.lang.Object object,
JsonConfig jsonConfig)
Creates a JSONArray.
Inspects the object type to call the correct JSONArray factory method. |
java.lang.Object |
get(int index)
Get the object value associated with an index.
|
boolean |
getBoolean(int index)
Get the boolean value associated with an index.
|
static java.lang.Class[] |
getCollectionType(java.beans.PropertyDescriptor pd,
boolean useGetter)
Get the collection type from a getter or setter, or null if no type was
found.
Contributed by [Matt Small @ WaveMaker]. |
static int[] |
getDimensions(JSONArray jsonArray)
Returns the number of dimensions suited for a java array.
|
double |
getDouble(int index)
Get the double value associated with an index.
|
int |
getInt(int index)
Get the int value associated with an index.
|
JSONArray |
getJSONArray(int index)
Get the JSONArray associated with an index.
|
JSONObject |
getJSONObject(int index)
Get the JSONObject associated with an index.
|
long |
getLong(int index)
Get the long value associated with an index.
|
java.lang.String |
getString(int index)
Get the string associated with an index.
|
int |
hashCode() |
int |
indexOf(java.lang.Object o) |
boolean |
isArray()
Returns true if this object is a JSONArray, false otherwise.
|
boolean |
isEmpty()
Returns true if this object has no elements or keys.
|
boolean |
isExpandElements() |
java.util.Iterator |
iterator()
Returns an Iterator for this JSONArray
|
java.lang.String |
join(java.lang.String separator)
Make a string from the contents of this JSONArray.
|
java.lang.String |
join(java.lang.String separator,
boolean stripQuotes)
Make a string from the contents of this JSONArray.
|
int |
lastIndexOf(java.lang.Object o) |
java.util.ListIterator |
listIterator() |
java.util.ListIterator |
listIterator(int index) |
java.lang.Object |
opt(int index)
Get the optional object value associated with an index.
|
boolean |
optBoolean(int index)
Get the optional boolean value associated with an index.
|
boolean |
optBoolean(int index,
boolean defaultValue)
Get the optional boolean value associated with an index.
|
double |
optDouble(int index)
Get the optional double value associated with an index.
|
double |
optDouble(int index,
double defaultValue)
Get the optional double value associated with an index.
|
int |
optInt(int index)
Get the optional int value associated with an index.
|
int |
optInt(int index,
int defaultValue)
Get the optional int value associated with an index.
|
JSONArray |
optJSONArray(int index)
Get the optional JSONArray associated with an index.
|
JSONObject |
optJSONObject(int index)
Get the optional JSONObject associated with an index.
|
long |
optLong(int index)
Get the optional long value associated with an index.
|
long |
optLong(int index,
long defaultValue)
Get the optional long value associated with an index.
|
java.lang.String |
optString(int index)
Get the optional string value associated with an index.
|
java.lang.String |
optString(int index,
java.lang.String defaultValue)
Get the optional string associated with an index.
|
java.lang.Object |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection collection) |
boolean |
removeAll(java.util.Collection collection,
JsonConfig jsonConfig) |
protected static void |
removeInstance(java.lang.Object instance)
Removes a reference for cycle detection check.
|
boolean |
retainAll(java.util.Collection collection) |
boolean |
retainAll(java.util.Collection collection,
JsonConfig jsonConfig) |
java.lang.Object |
set(int index,
java.lang.Object value) |
java.lang.Object |
set(int index,
java.lang.Object value,
JsonConfig jsonConfig) |
void |
setExpandElements(boolean expandElements) |
int |
size()
Get the number of elements in the JSONArray, included nulls.
|
java.util.List |
subList(int fromIndex,
int toIndex) |
java.lang.Object[] |
toArray()
Produce an Object[] with the contents of this JSONArray.
|
static java.lang.Object |
toArray(JSONArray jsonArray)
Creates a java array from a JSONArray.
|
static java.lang.Object |
toArray(JSONArray jsonArray,
java.lang.Class objectClass)
Creates a java array from a JSONArray.
|
static java.lang.Object |
toArray(JSONArray jsonArray,
java.lang.Class objectClass,
java.util.Map classMap)
Creates a java array from a JSONArray.
Any attribute is a JSONObject and matches a key in the classMap, it will be converted to that target class. The classMap has the following conventions: Every key must be an String. Every value must be a Class. A key may be a regular expression. |
static java.lang.Object |
toArray(JSONArray jsonArray,
JsonConfig jsonConfig)
Creates a java array from a JSONArray.
|
static java.lang.Object |
toArray(JSONArray jsonArray,
java.lang.Object root,
JsonConfig jsonConfig)
Creates a java array from a JSONArray.
|
java.lang.Object[] |
toArray(java.lang.Object[] array) |
static java.util.Collection |
toCollection(JSONArray jsonArray)
Returns a List or a Set taking generics into account.
|
static java.util.Collection |
toCollection(JSONArray jsonArray,
java.lang.Class objectClass)
Returns a List or a Set taking generics into account.
|
static java.util.Collection |
toCollection(JSONArray jsonArray,
JsonConfig jsonConfig)
Returns a List or a Set taking generics into account.
Contributed by [Matt Small @ WaveMaker]. |
JSONObject |
toJSONObject(JSONArray names)
Produce a JSONObject by combining a JSONArray of names with the values of
this JSONArray.
|
static java.util.List |
toList(JSONArray jsonArray)
Deprecated.
replaced by toCollection
|
static java.util.List |
toList(JSONArray jsonArray,
java.lang.Class objectClass)
Deprecated.
replaced by toCollection
|
static java.util.List |
toList(JSONArray jsonArray,
java.lang.Class objectClass,
java.util.Map classMap)
Deprecated.
replaced by toCollection
|
static java.util.List |
toList(JSONArray jsonArray,
JsonConfig jsonConfig)
Deprecated.
replaced by toCollection
|
static java.util.List |
toList(JSONArray jsonArray,
java.lang.Object root,
JsonConfig jsonConfig)
Creates a List from a JSONArray.
|
java.lang.String |
toString()
Make a JSON text of this JSONArray.
|
java.lang.String |
toString(int indentFactor)
Make a prettyprinted JSON text of this JSONArray.
|
java.lang.String |
toString(int indentFactor,
int indent)
Make a prettyprinted JSON text of this JSONArray.
|
java.io.Writer |
write(java.io.Writer writer)
Write the contents as JSON text to a writer.
|
protected void |
write(java.io.Writer writer,
net.sf.json.AbstractJSON.WritingVisitor visitor) |
java.io.Writer |
writeCanonical(java.io.Writer writer)
Writes the canonicalized form of this JSON object.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
write, writeCanonical
public static JSONArray fromObject(java.lang.Object object)
object
- JSONException
- if the object can not be converted to a proper
JSONArray.public static JSONArray fromObject(java.lang.Object object, JsonConfig jsonConfig)
object
- JSONException
- if the object can not be converted to a proper
JSONArray.public static java.lang.Class[] getCollectionType(java.beans.PropertyDescriptor pd, boolean useGetter) throws JSONException
JSONException
public static int[] getDimensions(JSONArray jsonArray)
public static java.lang.Object toArray(JSONArray jsonArray)
public static java.lang.Object toArray(JSONArray jsonArray, java.lang.Class objectClass)
public static java.lang.Object toArray(JSONArray jsonArray, java.lang.Class objectClass, java.util.Map classMap)
public static java.lang.Object toArray(JSONArray jsonArray, JsonConfig jsonConfig)
public static java.lang.Object toArray(JSONArray jsonArray, java.lang.Object root, JsonConfig jsonConfig)
public static java.util.Collection toCollection(JSONArray jsonArray)
public static java.util.Collection toCollection(JSONArray jsonArray, java.lang.Class objectClass)
public static java.util.Collection toCollection(JSONArray jsonArray, JsonConfig jsonConfig)
public static java.util.List toList(JSONArray jsonArray)
toCollection(JSONArray)
public static java.util.List toList(JSONArray jsonArray, java.lang.Class objectClass)
toCollection(JSONArray,Class)
public static java.util.List toList(JSONArray jsonArray, java.lang.Class objectClass, java.util.Map classMap)
#toCollection(JSONArray,Class,Map)
public static java.util.List toList(JSONArray jsonArray, JsonConfig jsonConfig)
toCollection(JSONArray,JsonConfig)
public static java.util.List toList(JSONArray jsonArray, java.lang.Object root, JsonConfig jsonConfig)
public void add(int index, java.lang.Object value)
add
in interface java.util.List<java.lang.Object>
public void add(int index, java.lang.Object value, JsonConfig jsonConfig)
public boolean add(java.lang.Object value)
add
in interface java.util.Collection<java.lang.Object>
add
in interface java.util.List<java.lang.Object>
public boolean add(java.lang.Object value, JsonConfig jsonConfig)
public boolean addAll(java.util.Collection collection)
addAll
in interface java.util.Collection<java.lang.Object>
addAll
in interface java.util.List<java.lang.Object>
public boolean addAll(java.util.Collection collection, JsonConfig jsonConfig)
public boolean addAll(int index, java.util.Collection collection)
addAll
in interface java.util.List<java.lang.Object>
public boolean addAll(int index, java.util.Collection collection, JsonConfig jsonConfig)
public void clear()
clear
in interface java.util.Collection<java.lang.Object>
clear
in interface java.util.List<java.lang.Object>
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<java.lang.Object>
contains
in interface java.util.List<java.lang.Object>
public boolean contains(java.lang.Object o, JsonConfig jsonConfig)
public boolean containsAll(java.util.Collection collection)
containsAll
in interface java.util.Collection<java.lang.Object>
containsAll
in interface java.util.List<java.lang.Object>
public boolean containsAll(java.util.Collection collection, JsonConfig jsonConfig)
public JSONArray discard(int index)
index
- the index of the element.public JSONArray discard(java.lang.Object o)
index
- the element.public JSONArray element(boolean value)
value
- A boolean value.public JSONArray element(java.util.Collection value)
value
- A Collection value.public JSONArray element(java.util.Collection value, JsonConfig jsonConfig)
value
- A Collection value.public JSONArray element(double value)
value
- A double value.JSONException
- if the value is not finite.public JSONArray element(int value)
value
- An int value.public JSONArray element(int index, boolean value)
index
- The subscript.value
- A boolean value.JSONException
- If the index is negative.public JSONArray element(int index, java.util.Collection value)
index
- The subscript.value
- A Collection value.JSONException
- If the index is negative or if the value is not
finite.public JSONArray element(int index, java.util.Collection value, JsonConfig jsonConfig)
index
- The subscript.value
- A Collection value.JSONException
- If the index is negative or if the value is not
finite.public JSONArray element(int index, double value)
index
- The subscript.value
- A double value.JSONException
- If the index is negative or if the value is not
finite.public JSONArray element(int index, int value)
index
- The subscript.value
- An int value.JSONException
- If the index is negative.public JSONArray element(int index, long value)
index
- The subscript.value
- A long value.JSONException
- If the index is negative.public JSONArray element(int index, java.util.Map value)
index
- The subscript.value
- The Map value.JSONException
- If the index is negative or if the the value is an
invalid number.public JSONArray element(int index, java.util.Map value, JsonConfig jsonConfig)
index
- The subscript.value
- The Map value.JSONException
- If the index is negative or if the the value is an
invalid number.public JSONArray element(int index, java.lang.Object value)
index
- The subscript.value
- An object value. The value should be a Boolean, Double,
Integer, JSONArray, JSONObject, JSONFunction, Long, String,
JSONString or the JSONNull object.JSONException
- If the index is negative or if the the value is an
invalid number.public JSONArray element(int index, java.lang.Object value, JsonConfig jsonConfig)
index
- The subscript.value
- An object value. The value should be a Boolean, Double,
Integer, JSONArray, JSONObject, JSONFunction, Long, String,
JSONString or the JSONNull object.JSONException
- If the index is negative or if the the value is an
invalid number.public JSONArray element(int index, java.lang.String value)
index
- The subscript.value
- A String value.JSONException
- If the index is negative or if the the value is an
invalid number.public JSONArray element(int index, java.lang.String value, JsonConfig jsonConfig)
index
- The subscript.value
- A String value.JSONException
- If the index is negative or if the the value is an
invalid number.public JSONArray element(JSONNull value)
value
- An JSON value.public JSONArray element(JSONObject value)
value
- An JSON value.public JSONArray element(long value)
value
- A long value.public JSONArray element(java.util.Map value)
value
- A Map value.public JSONArray element(java.util.Map value, JsonConfig jsonConfig)
value
- A Map value.public JSONArray element(java.lang.Object value)
value
- An object value. The value should be a Boolean, Double,
Integer, JSONArray, JSONObject, JSONFunction, Long, String,
JSONString or the JSONNull object.public JSONArray element(java.lang.Object value, JsonConfig jsonConfig)
value
- An object value. The value should be a Boolean, Double,
Integer, JSONArray, JSONObject, JSONFunction, Long, String,
JSONString or the JSONNull object.public JSONArray element(java.lang.String value)
value
- A String value.public JSONArray element(java.lang.String value, JsonConfig jsonConfig)
value
- A String value.public boolean equals(java.lang.Object obj)
equals
in interface java.util.Collection<java.lang.Object>
equals
in interface java.util.List<java.lang.Object>
equals
in class java.lang.Object
public java.lang.Object get(int index)
get
in interface java.util.List<java.lang.Object>
index
- The index must be between 0 and size() - 1.public boolean getBoolean(int index)
index
- The index must be between 0 and size() - 1.JSONException
- If there is no value for the index or if the value
is not convertable to boolean.public double getDouble(int index)
index
- The index must be between 0 and size() - 1.JSONException
- If the key is not found or if the value cannot be
converted to a number.public int getInt(int index)
index
- The index must be between 0 and size() - 1.JSONException
- If the key is not found or if the value cannot be
converted to a number. if the value cannot be converted to a
number.public JSONArray getJSONArray(int index)
index
- The index must be between 0 and size() - 1.JSONException
- If there is no value for the index. or if the value
is not a JSONArraypublic JSONObject getJSONObject(int index)
index
- subscriptJSONException
- If there is no value for the index or if the value
is not a JSONObjectpublic long getLong(int index)
index
- The index must be between 0 and size() - 1.JSONException
- If the key is not found or if the value cannot be
converted to a number.public java.lang.String getString(int index)
index
- The index must be between 0 and size() - 1.JSONException
- If there is no value for the index.public int hashCode()
hashCode
in interface java.util.Collection<java.lang.Object>
hashCode
in interface java.util.List<java.lang.Object>
hashCode
in class java.lang.Object
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<java.lang.Object>
public boolean isArray()
JSON
public boolean isEmpty()
JSON
public boolean isExpandElements()
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable<java.lang.Object>
iterator
in interface java.util.Collection<java.lang.Object>
iterator
in interface java.util.List<java.lang.Object>
public java.lang.String join(java.lang.String separator)
separator
string is inserted between each element. Warning:
This method assumes that the data structure is acyclical.separator
- A string that will be inserted between the elements.JSONException
- If the array contains an invalid number.public java.lang.String join(java.lang.String separator, boolean stripQuotes)
separator
string is inserted between each element. Warning:
This method assumes that the data structure is acyclical.separator
- A string that will be inserted between the elements.JSONException
- If the array contains an invalid number.public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<java.lang.Object>
public java.util.ListIterator listIterator()
listIterator
in interface java.util.List<java.lang.Object>
public java.util.ListIterator listIterator(int index)
listIterator
in interface java.util.List<java.lang.Object>
public java.lang.Object opt(int index)
index
- The index must be between 0 and size() - 1.public boolean optBoolean(int index)
index
- The index must be between 0 and size() - 1.public boolean optBoolean(int index, boolean defaultValue)
index
- The index must be between 0 and size() - 1.defaultValue
- A boolean default.public double optDouble(int index)
index
- The index must be between 0 and size() - 1.public double optDouble(int index, double defaultValue)
index
- subscriptdefaultValue
- The default value.public int optInt(int index)
index
- The index must be between 0 and size() - 1.public int optInt(int index, int defaultValue)
index
- The index must be between 0 and size() - 1.defaultValue
- The default value.public JSONArray optJSONArray(int index)
index
- subscriptpublic JSONObject optJSONObject(int index)
index
- The index must be between 0 and size() - 1.public long optLong(int index)
index
- The index must be between 0 and size() - 1.public long optLong(int index, long defaultValue)
index
- The index must be between 0 and size() - 1.defaultValue
- The default value.public java.lang.String optString(int index)
index
- The index must be between 0 and size() - 1.public java.lang.String optString(int index, java.lang.String defaultValue)
index
- The index must be between 0 and size() - 1.defaultValue
- The default value.public java.lang.Object remove(int index)
remove
in interface java.util.List<java.lang.Object>
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<java.lang.Object>
remove
in interface java.util.List<java.lang.Object>
public boolean removeAll(java.util.Collection collection)
removeAll
in interface java.util.Collection<java.lang.Object>
removeAll
in interface java.util.List<java.lang.Object>
public boolean removeAll(java.util.Collection collection, JsonConfig jsonConfig)
public boolean retainAll(java.util.Collection collection)
retainAll
in interface java.util.Collection<java.lang.Object>
retainAll
in interface java.util.List<java.lang.Object>
public boolean retainAll(java.util.Collection collection, JsonConfig jsonConfig)
public java.lang.Object set(int index, java.lang.Object value)
set
in interface java.util.List<java.lang.Object>
public java.lang.Object set(int index, java.lang.Object value, JsonConfig jsonConfig)
public void setExpandElements(boolean expandElements)
public int size()
public java.util.List subList(int fromIndex, int toIndex)
subList
in interface java.util.List<java.lang.Object>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<java.lang.Object>
toArray
in interface java.util.List<java.lang.Object>
public java.lang.Object[] toArray(java.lang.Object[] array)
toArray
in interface java.util.Collection<java.lang.Object>
toArray
in interface java.util.List<java.lang.Object>
public JSONObject toJSONObject(JSONArray names)
names
- A JSONArray containing a list of key strings. These will be
paired with the values.JSONException
- If any of the names are null.public java.lang.String toString()
Warning: This method assumes that the data structure is acyclical.
toString
in class java.lang.Object
public java.lang.String toString(int indentFactor)
toString
in interface JSON
indentFactor
- The number of spaces to add to each level of
indentation.[
(left
bracket) and ending with ]
(right
bracket).JSONException
public java.lang.String toString(int indentFactor, int indent)
toString
in interface JSON
indentFactor
- The number of spaces to add to each level of
indentation.indent
- The indention of the top level.JSONException
protected void write(java.io.Writer writer, net.sf.json.AbstractJSON.WritingVisitor visitor) throws java.io.IOException
java.io.IOException
protected JSONArray addString(java.lang.String str)
protected java.lang.Object _processValue(java.lang.Object value, JsonConfig jsonConfig)
protected static boolean addInstance(java.lang.Object instance)
instance
- the reference to addprotected static void fireArrayEndEvent(JsonConfig jsonConfig)
protected static void fireArrayStartEvent(JsonConfig jsonConfig)
protected static void fireElementAddedEvent(int index, java.lang.Object element, JsonConfig jsonConfig)
index
- the index where the element was addedelement
- the added elementprotected static void fireErrorEvent(JSONException jsone, JsonConfig jsonConfig)
jsone
- the thrown exceptionprotected static void fireObjectEndEvent(JsonConfig jsonConfig)
protected static void fireObjectStartEvent(JsonConfig jsonConfig)
protected static void firePropertySetEvent(java.lang.String key, java.lang.Object value, boolean accumulated, JsonConfig jsonConfig)
key
- the name of the propertyvalue
- the value of the propertyaccumulated
- if the value has been accumulated over 'key'protected static void fireWarnEvent(java.lang.String warning, JsonConfig jsonConfig)
warning
- the warning messageprotected static void removeInstance(java.lang.Object instance)
public final java.io.Writer write(java.io.Writer writer) throws java.io.IOException
JSON
Warning: This method assumes that the data structure is acyclical.
public final java.io.Writer writeCanonical(java.io.Writer writer) throws java.io.IOException
JSON
writeCanonical
in interface JSON
java.io.IOException
Copyright © 2006-2013 Json-lib. All Rights Reserved.