JsonElements each of
which can be of a different type. This is an ordered list, meaning that the order in which
elements are added is preserved. This class does not support null values. If null
is provided as element argument to any of the methods, it is converted to a JsonNull.
JsonArray only implements the Iterable interface but not the List
interface. A List view of it can be obtained with asList().
See the JsonElement documentation for details on how to convert JsonArray and
generally any JsonElement from and to JSON.
| Modifier and Type | Field and Description |
|---|---|
| private final ArrayList |
| Access | Constructor and Description |
|---|---|
| public | |
| public | JsonArray(int
initial capacity. capacity)Creates an empty JsonArray with the desired initial capacity. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | |
| public void | add(JsonElement
the element that needs to be added to the array. element)Adds the specified element to self. |
| public void | |
| public List | |
| public boolean | Returns: true if this array contains the specified element.whose presence in this array is to be tested element)Returns true if this array contains the specified element. |
| public JsonArray | deepCopy()
Implements abstract com. Creates a deep copy of this element and all its children. |
| public boolean | equals(Object o)
Overrides java. Returns whether the other object is equal to this. |
| public JsonElement | Returns: the element present at the i-th index.the index of the element that is being sought. i)Returns the i-th element of the array. |
| public BigDecimal | Returns: this element as aBigDecimal if it is single element array.Overrides com. Convenience method to get this array as a |
| public BigInteger | Returns: this element as aBigInteger if it is single element array.Overrides com. Convenience method to get this array as a |
| public boolean | Returns: this element as a boolean if it is single element array.Overrides com. Convenience method to get this array as a boolean if it contains a single element. |
| public byte | Returns: this element as a primitive byte if it is single element array.Overrides com. Convenience method to get this array as a primitive byte if it contains a single element. |
| public char | Returns: this element as a primitive short if it is single element array.Overrides com.
Deprecated
This method is misleading, as it does not get this element as a char but rather as
a string's first character.
Convenience method to get this array as a character if it contains a single element. |
| public double | Returns: this element as a double if it is single element array.Overrides com. Convenience method to get this array as a double if it contains a single element. |
| public float | Returns: this element as a float if it is single element array.Overrides com. Convenience method to get this array as a float if it contains a single element. |
| public int | Returns: this element as an integer if it is single element array.Overrides com. Convenience method to get this array as an integer if it contains a single element. |
| public long | Returns: this element as a long if it is single element array.Overrides com. Convenience method to get this array as a long if it contains a single element. |
| public Number | Returns: this element as a number if it is single element array.Overrides com. Convenience method to get this array as a |
| public short | Returns: this element as a primitive short if it is single element array.Overrides com. Convenience method to get this array as a primitive short if it contains a single element. |
| private JsonElement | |
| public String | Returns: this element as a String if it is single element array.Overrides com. Convenience method to get this array as a |
| public int | |
| public boolean | |
| public Iterator | Returns: an iterator to navigate the elements of the array.Implements java. Returns an iterator to navigate the elements of the array. |
| public boolean | Returns: true if this array contained the specified element, false otherwiseelement to be removed from this array, if present element)Removes the first occurrence of the specified element from this array, if it is present. |
| public JsonElement | Returns: the element previously at the specified positionindex the index of the element to be removed index)Removes the element at the specified position in this array. |
| public JsonElement | Returns: the element previously at the specified positionindex of the element to replace index, JsonElement element to be stored at the specified position element)Replaces the element at the specified position in this array with the specified element. |
| public int |
| elements | back to summary |
|---|---|
| private final ArrayList<JsonElement> elements | |
| JsonArray | back to summary |
|---|---|
| public JsonArray() Creates an empty JsonArray.
| |
| JsonArray | back to summary |
|---|---|
| public JsonArray(int capacity) Creates an empty JsonArray with the desired initial capacity.
| |
| add | back to summary |
|---|---|
| public void add(Boolean bool) Adds the specified boolean to self.
| |
| add | back to summary |
|---|---|
| public void add(Character character) Adds the specified character to self.
| |
| add | back to summary |
|---|---|
| public void add(Number number) Adds the specified number to self.
| |
| add | back to summary |
|---|---|
| public void add(String string) Adds the specified string to self.
| |
| add | back to summary |
|---|---|
| public void add(JsonElement element) Adds the specified element to self.
| |
| addAll | back to summary |
|---|---|
| public void addAll(JsonArray array) Adds all the elements of the specified array to self.
| |
| asList | back to summary |
|---|---|
| public List Returns a mutable The
| |
| contains | back to summary |
|---|---|
| public boolean contains(JsonElement element) Returns true if this array contains the specified element.
| |
| deepCopy | back to summary |
|---|---|
| public JsonArray deepCopy() Implements abstract com. Creates a deep copy of this element and all its children.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Returns whether the other object is equal to this. This method only considers the other object
to be equal if it is an instance of
| |
| get | back to summary |
|---|---|
| public JsonElement get(int i) Returns the i-th element of the array.
| |
| getAsBigDecimal | back to summary |
|---|---|
| public BigDecimal getAsBigDecimal() Overrides com. Convenience method to get this array as a
| |
| getAsBigInteger | back to summary |
|---|---|
| public BigInteger getAsBigInteger() Overrides com. Convenience method to get this array as a
| |
| getAsBoolean | back to summary |
|---|---|
| public boolean getAsBoolean() Overrides com. Convenience method to get this array as a boolean if it contains a single element. This method
calls
| |
| getAsByte | back to summary |
|---|---|
| public byte getAsByte() Overrides com. Convenience method to get this array as a primitive byte if it contains a single element. This
method calls
| |
| getAsCharacter | back to summary |
|---|---|
| public char getAsCharacter() Overrides com. Deprecated This method is misleading, as it does not get this element as a char but rather as a string's first character. Convenience method to get this array as a character if it contains a single element. This
method calls
| |
| getAsDouble | back to summary |
|---|---|
| public double getAsDouble() Overrides com. Convenience method to get this array as a double if it contains a single element. This method
calls
| |
| getAsFloat | back to summary |
|---|---|
| public float getAsFloat() Overrides com. Convenience method to get this array as a float if it contains a single element. This method
calls
| |
| getAsInt | back to summary |
|---|---|
| public int getAsInt() Overrides com. Convenience method to get this array as an integer if it contains a single element. This method
calls
| |
| getAsLong | back to summary |
|---|---|
| public long getAsLong() Overrides com. Convenience method to get this array as a long if it contains a single element. This method
calls
| |
| getAsNumber | back to summary |
|---|---|
| public Number getAsNumber() Overrides com. Convenience method to get this array as a
| |
| getAsShort | back to summary |
|---|---|
| public short getAsShort() Overrides com. Convenience method to get this array as a primitive short if it contains a single element. This
method calls
| |
| getAsSingleElement | back to summary |
|---|---|
| private JsonElement getAsSingleElement() | |
| getAsString | back to summary |
|---|---|
| public String getAsString() Overrides com. Convenience method to get this array as a
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code of this array. This method calculates the hash code based on the elements of this array.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Returns true if the array is empty.
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Returns an iterator to navigate the elements of the array. Since the array is an ordered list, the iterator navigates the elements in the order they were inserted.
| |
| remove | back to summary |
|---|---|
| public boolean remove(JsonElement element) Removes the first occurrence of the specified element from this array, if it is present. If the array does not contain the element, it is unchanged.
| |
| remove | back to summary |
|---|---|
| public JsonElement remove(int index) Removes the element at the specified position in this array. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the array.
| |
| set | back to summary |
|---|---|
| public JsonElement set(int index, JsonElement element) Replaces the element at the specified position in this array with the specified element.
| |
| size | back to summary |
|---|---|
| public int size() Returns the number of elements in the array.
| |