Added in API level 1

JSONArray

public class JSONArray
extends Object

java.lang.Object
   ↳ org.json.JSONArray


A dense indexed sequence of values. Values may be any mix of JSONObjects, other JSONArrays, Strings, Booleans, Integers, Longs, Doubles, null or JSONObject.NULL. Values may not be NaNs, infinities, or of any type not listed here.

JSONArray has the same type coercion behavior and optional/mandatory accessors as JSONObject. See that class' documentation for details.

Warning: this class represents null in two incompatible ways: the standard Java null reference, and the sentinel value JSONObject.NULL. In particular, get fails if the requested index holds the null reference, but succeeds if it holds JSONObject.NULL.

Instances of this class are not thread safe. Although this class is nonfinal, it was not designed for inheritance and should not be subclassed. In particular, self-use by overridable methods is not specified. See Effective Java Item 17, "Design and Document or inheritance or else prohibit it" for further information.

Summary

Public constructors

JSONArray()

Creates a JSONArray with no values.

JSONArray(Object array)

Creates a new JSONArray with values from the given primitive array.

JSONArray(String json)

Creates a new JSONArray with values from the JSON string.

JSONArray(Collection<E> copyFrom)

Creates a new JSONArray by copying all values from the given collection.

JSONArray(JSONTokener readFrom)

Creates a new JSONArray with values from the next array in the tokener.

Public methods

boolean equals(Object o)

Indicates whether some other object is "equal to" this one.

Object get(int index)

Returns the value at index.