Google Web Toolkit
Search Google Code:

# Class JSONArray

public class JSONArray
extends JSONValue
Represents an array of JSONValue objects.

## Constructors

JSONArray() | Creates an empty JSONArray.
JSONArray(JavaScriptObject) | Creates a new JSONArray from the supplied JavaScriptObject representing a JavaScript array.

## Methods

get(int) | Returns the value at the specified index position.
isArray() | Returns `this`, as this is a JSONArray.
set(int, JSONValue) | Sets the specified index to the given value.
size() | Returns the number of elements in this array.
toString() | Create the JSON encoded string representation of this JSONArray instance.

## Constructor Detail

### JSONArray

public JSONArray()
Creates an empty JSONArray.

### JSONArray

public JSONArray(JavaScriptObject arr)
Creates a new JSONArray from the supplied JavaScriptObject representing a JavaScript array.

#### Parameters

arr
  a JavaScript array

## Method Detail

### get

public JSONValue get(int index)
throws JSONException
Returns the value at the specified index position.

#### Parameters

index
  the index of the array item to retrieve

#### Return Value

the value at this index, or `null` if this index is empty

### isArray

public JSONArray isArray()
Returns `this`, as this is a JSONArray.

### set

public JSONValue set(int index, JSONValue jsonValue)
Sets the specified index to the given value.

#### Parameters

index
  the index to set
jsonValue
  the value to set

#### Return Value

the previous value at this index, or `null` if this index was empty

### size

public int size()
Returns the number of elements in this array.

#### Return Value

size of this array

### toString

public String toString()
throws JSONException
Create the JSON encoded string representation of this JSONArray instance. This method may take a long time to execute if the underlying array is large.