Interface JSONArray

All Superinterfaces:
Formattable, Iterable<JSONValue>, JSONValue
All Known Implementing Classes:
JSONArrayImpl

@ClassVersion(sourceVersion="$Id: JSONArray.java 1258 2026-06-04 18:33:06Z tquadrat $") @API(status=STABLE, since="0.25.0") public sealed interface JSONArray extends Iterable<JSONValue>, JSONValue permits JSONArrayImpl

The definition of a JSON array.

Basically, aa JSON array is dense, meaning that an array with the maximum index i has exactly i + 1 elements – although some of these elements could be null.

The add(T) methods will add the given value to the end of the array, while the add(int,T) methods will insert the given value at the position identified by the given index; the already existing values at that position and above will be moved to the next higher position. If the index is equal to the size of the array, the value will be added to the end of the array. That means that add( value ) and add( size(), value ) are equivalent. A value for index that is greater than the size of the array (or less than 0) will cause an IndexOutOfBoundsException to be thrown.

The set(int,T) methods will replace the value at the given index; this means, that after a call to set(int,JSONValue) the size of this array remains the same, while a call to add(JSONValue) or add(int,JSONValue) increases the array size by one.

Obviously must the value for the index argument of a set() match an existing array position; otherwise an IndexOutOfBoundsException is thrown.

An instance of JSONArray is not thread-safe.

Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: JSONArray.java 1258 2026-06-04 18:33:06Z tquadrat $
Since:
0.25.0
UML Diagram
UML Diagram for "org.tquadrat.foundation.jsonbuilder.JSONArray"

UML Diagram for "org.tquadrat.foundation.jsonbuilder.JSONArray"

UML Diagram for "org.tquadrat.foundation.jsonbuilder.JSONArray"
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    add(boolean value)
    Appends the given value as a new element to the end of this array.
    void
    add(double value)
    Appends the given value as a new element to the end of this array.
    void
    add(float value)
    Appends the given value as a new element to the end of this array.
    void
    add(int value)
    Appends the given value as a new element to the end of this array.
    default void
    add(int index, boolean value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, double value)
    Inserts the given value as a new element to the given postion of this array and moves the other elements to a by one higher index.
    void
    add(int index, float value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, int value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, long value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, Double value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, Float value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, Integer value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, Long value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, String value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, BigDecimal value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, BigInteger value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    void
    add(int index, JSONValue value)
    Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.
    <T extends Dimension>
    void
    add(int index, DimensionedValue<T> value, T targetUnit)
    Inserts the given value as a new element to the given postion of this array and moves the other elements to a by one higher index.
    void
    add(long value)
    Appends the given value as a new element to the end of this array.
    void
    add(Double value)
    Appends the given value as a new element to the end of this array.
    void
    add(Float value)
    Appends the given value as a new element to the end of this array.
    void
    add(Integer value)
    Appends the given value as a new element to the end of this array.
    void
    add(Long value)
    Appends the given value as a new element to the end of this array.
    void
    add(String value)
    Appends the given value as a new element to the end of this array.
    void
    add(BigDecimal value)
    Appends the given value as a new element to the end of this array.
    void
    add(BigInteger value)
    Appends the given value as a new element to the end of this array.
    void
    add(JSONValue value)
    Appends the given value as a new element to the end of this array.
    <T extends Dimension>
    void
    add(DimensionedValue<T> value, T targetUnit)
    Appends the given value as a new element to the end of this array.
    boolean
    Appends the given array to this one.
    Adds a new empty instance of JSONArray to this array and returns that.
    addArray(int index)
    Adds a new empty instance of JSONArray to this array at the given index and returns that.
    Adds a new empty instance of JSONObject to this array and returns that.
    addObject(int index)
    Adds a new empty instance of JSONObject to this array at the given index and returns that.
    get(int index)
    Returns the value of the element at the specied index in this array.
    default JSONArray
    getArray(int index)
    Convenience method that returns the value with the specified index as a JSONArray.
    default BigDecimal
    getBigDecimal(int index)
    Convenience method that returns the value with the specified index as a BigDecimal.
    default BigInteger
    getBigInteger(int index)
    Convenience method that returns the value with the specified index as a BigInteger.
    default boolean
    getBoolean(int index)
    Convenience method that returns the value with the specified index as a boolean.
    default double
    getDouble(int index)
    Convenience method that returns the value with the specified index as a double.
    default float
    getFloat(int index)
    Convenience method that returns the value with the specified index as a float.
    default int
    getInt(int index)
    Convenience method that returns the value with the specified index as a int.
    default long
    getLong(int index)
    Convenience method that returns the value with the specified index as a long.
    default JSONObject
    getObject(int index)
    Convenience method that returns the value with the specified index as a JSONObject.
    default String
    getString(int index)
    Convenience method that returns the value with the specified index as a String.
    boolean
    Checks whether this array has elements.
    void
    remove(int index)
    Removes the element with the specified index from this array.
    void
    remove(JSONValue element)
    Removes the first occurrence of the specified element from this array, if it is present.
    default void
    set(int index, boolean value)
    Sets the value of the element with the specified index to the JSON representation of the specified boolean value.
    void
    set(int index, double value)
    Sets the value of the element with the specified index to the JSON representation of the specified double value.
    void
    set(int index, float value)
    Sets the value of the element with the specified index to the JSON representation of the specified float value.
    void
    set(int index, int value)
    Sets the value of the element with the specified index to the JSON representation of the specified int value.
    void
    set(int index, long value)
    Sets the value of the element with the specified index to the JSON representation of the specified long value.
    void
    set(int index, Double value)
    Sets the value of the element with the specified index to the JSON representation of the specified Double value.
    void
    set(int index, Float value)
    Sets the value of the element with the specified index to the JSON representation of the specified Float value.
    void
    set(int index, Integer value)
    Sets the value of the element with the specified index to the JSON representation of the specified Integer value.
    void
    set(int index, Long value)
    Sets the value of the element with the specified index to the JSON representation of the specified Long value.
    void
    set(int index, String value)
    Sets the value of the element with the specified index to the JSON representation of the specified String value.
    void
    set(int index, BigDecimal value)
    Sets the value of the element with the specified index to the JSON representation of the specified BigDecimal value.
    void
    set(int index, BigInteger value)
    Sets the value of the element with the specified index to the JSON representation of the specified BigInteger value.
    void
    set(int index, JSONValue value)
    Sets the value of the element with the specified index to the given JSONValue instance.
    <T extends Dimension>
    void
    set(int index, DimensionedValue<T> value, T targetUnit)
    Sets the value of the element with the specified index to the JSON representation of the specified DimensionedValue value.
    setArray(int index)
    Sets a new empty instance of JSONArray to this array at the given index and returns that.
    setObject(int index)
    Sets a new empty instance of JSONObject to this array at the given index and returns that.
    int
    Returns the number of elements for this array.

    Methods inherited from interface Iterable

    forEach, iterator, spliterator
  • Method Details

    • add

      void add(BigDecimal value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(BigInteger value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      default void add(boolean value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(double value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      <T extends Dimension> void add(DimensionedValue<T> value, T targetUnit)

      Appends the given value as a new element to the end of this array.

      Type Parameters:
      T - The type of the dimension for the value.
      Parameters:
      value - The value.
      targetUnit - The dimension for the output.
      See Also:
    • add

      void add(Double value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(float value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(Float value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(int value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(Integer value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(JSONValue value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(long value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(Long value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(String value)

      Appends the given value as a new element to the end of this array.

      Parameters:
      value - The value to add.
    • add

      void add(int index, BigDecimal value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, BigInteger value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      default void add(int index, boolean value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      <T extends Dimension> void add(int index, DimensionedValue<T> value, T targetUnit) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion of this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Type Parameters:
      T - The type of the dimension for the value.
      Parameters:
      index - The index.
      value - The value.
      targetUnit - The dimension for the output.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
      See Also:
    • add

      void add(int index, double value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion of this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, Double value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, float value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, Float value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, int value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, Integer value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, JSONValue value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, long value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, Long value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • add

      void add(int index, String value) throws IndexOutOfBoundsException

      Inserts the given value as a new element to the given postion this array and moves the other elements to a by one higher index.

      If index is equals to the size of the array, the element is appended to the end of the array.

      Parameters:
      index - The index.
      value - The value to add.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • addAll

      boolean addAll(JSONArray array)

      Appends the given array to this one. This mean that the elements of the given array are added to this one.

      Parameters:
      array - The other array.
      Returns:
      true if the call to this method changed this instance.
    • addArray

      Adds a new empty instance of JSONArray to this array and returns that.

      Returns:
      The freshly created JSONArray.
    • addArray

      Adds a new empty instance of JSONArray to this array at the given index and returns that.

      Parameters:
      index - The index.
      Returns:
      The freshly created JSONArray.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • addObject

      Adds a new empty instance of JSONObject to this array and returns that.

      Returns:
      The freshly created JSONObject.
    • addObject

      Adds a new empty instance of JSONObject to this array at the given index and returns that.

      Parameters:
      index - The index.
      Returns:
      The freshly created JSONObject.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than the size of the array.
    • get

      Returns the value of the element at the specied index in this array.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The element; will never be null.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getArray

      Convenience method that returns the value with the specified index as a JSONArray.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a JSON Array.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getBigDecimal

      Convenience method that returns the value with the specified index as a BigDecimal.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a number.
      NumberFormatException - The element is a number, but cannot be parsed to a valid BigDecimal.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getBigInteger

      Convenience method that returns the value with the specified index as a BigInteger.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a number.
      NumberFormatException - The element is a number, but cannot be parsed to a valid BigInteger.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getBoolean

      default boolean getBoolean(int index) throws IllegalStateException, IndexOutOfBoundsException

      Convenience method that returns the value with the specified index as a boolean.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a boolean.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getDouble

      Convenience method that returns the value with the specified index as a double.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a number.
      NumberFormatException - The element is a number, but cannot be parsed to a valid double.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getFloat

      Convenience method that returns the value with the specified index as a float.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a number.
      NumberFormatException - The element is a number, but cannot be parsed to a valid float.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getInt

      Convenience method that returns the value with the specified index as a int.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a number.
      NumberFormatException - The element is a number, but cannot be parsed to a valid int.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getLong

      Convenience method that returns the value with the specified index as a long.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a number.
      NumberFormatException - The element is a number, but cannot be parsed to a valid long.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getObject

      Convenience method that returns the value with the specified index as a JSONObject.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a JSON Object.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • getString

      Convenience method that returns the value with the specified index as a String.

      Parameters:
      index - The index of the element whose value is to be returned.
      Returns:
      The value of the element with the specified index.
      Throws:
      IllegalStateException - The element is not a String.
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • isEmpty

      boolean isEmpty()
      Checks whether this array has elements.
      Returns:
      true if the object does not have any elements, false otherwise.
    • remove

      void remove(int index) throws IndexOutOfBoundsException

      Removes the element with the specified index from this array.

      Parameters:
      index - The index of the element to remove.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • remove

      void remove(JSONValue element)

      Removes the first occurrence of the specified element from this array, if it is present. If this list does not contain the element, it remains unchanged.

      More formally, this method removes the element with the lowest index i such that Objects.equals(o, get(i)) (if such an element exists).

      Parameters:
      element - The element to remove.
    • set

      void set(int index, BigDecimal value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified BigDecimal value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, BigInteger value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified BigInteger value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      default void set(int index, boolean value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified boolean value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      <T extends Dimension> void set(int index, DimensionedValue<T> value, T targetUnit) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified DimensionedValue value.

      Type Parameters:
      T - The type of the dimension for the value.
      Parameters:
      index - The index.
      value - The value.
      targetUnit - The dimension for the output.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
      See Also:
    • set

      void set(int index, double value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified double value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, Double value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified Double value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, int value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified int value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, float value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified float value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, Float value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified Float value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, Integer value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified Integer value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, JSONValue value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the given JSONValue instance.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, long value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified long value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, Long value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified Long value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • set

      void set(int index, String value) throws IndexOutOfBoundsException

      Sets the value of the element with the specified index to the JSON representation of the specified String value.

      Parameters:
      index - The index of the element to replace.
      value - The value to set to the member.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • setArray

      Sets a new empty instance of JSONArray to this array at the given index and returns that.

      Parameters:
      index - The index.
      Returns:
      The freshly created JSONArray.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • setObject

      Sets a new empty instance of JSONObject to this array at the given index and returns that.

      Parameters:
      index - The index.
      Returns:
      The freshly created JSONObject.
      Throws:
      IndexOutOfBoundsException - The index is less than 0 or greater than or equal to the size of the array.
    • size

      int size()
      Returns the number of elements for this array.
      Returns:
      The number of members in this object.