Class JsonArray

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, RandomAccess, SequencedCollection<Object>

public class JsonArray extends ArrayList<Object>
Extends an ArrayList with helper methods to determine the underlying JSON type of the list element.
See Also:
  • Constructor Details

    • JsonArray

      public JsonArray()
      Creates an empty JsonArray with the default capacity.
    • JsonArray

      public JsonArray(int initialCapacity)
      Creates an empty JsonArray with the default initial capacity.
    • JsonArray

      public JsonArray(Collection<?> collection)
      Creates an empty JsonArray from the given collection of objects.
  • Method Details

    • from

      public static JsonArray from(Object... contents)
      Creates a JsonArray from an array of contents.
    • builder

      public static JsonBuilder<JsonArray> builder()
      Creates a JsonBuilder for a JsonArray.
    • get

      public Object get(int key)
      Returns the underlying object at the given index, or null if it does not exist.
      Specified by:
      get in interface List<Object>
      Overrides:
      get in class ArrayList<Object>
    • getArray

      public JsonArray getArray(int key)
      Returns the JsonArray at the given index, or null if it does not exist or is the wrong type.
    • getArray

      public JsonArray getArray(int key, JsonArray default_)
      Returns the JsonArray at the given index, or the default if it does not exist or is the wrong type.
    • getBoolean

      public boolean getBoolean(int key)
      Returns the Boolean at the given index, or false if it does not exist or is the wrong type.
    • getBoolean

      public boolean getBoolean(int key, Boolean default_)
      Returns the Boolean at the given index, or the default if it does not exist or is the wrong type.
    • getDouble

      public double getDouble(int key)
      Returns the Double at the given index, or 0.0 if it does not exist or is the wrong type.
    • getDouble

      public double getDouble(int key, double default_)
      Returns the Double at the given index, or the default if it does not exist or is the wrong type.
    • getFloat

      public float getFloat(int key)
      Returns the Float at the given index, or 0.0f if it does not exist or is the wrong type.
    • getFloat

      public float getFloat(int key, float default_)
      Returns the Float at the given index, or the default if it does not exist or is the wrong type.
    • getInt

      public int getInt(int key)
      Returns the Integer at the given index, or 0 if it does not exist or is the wrong type.
    • getInt

      public int getInt(int key, int default_)
      Returns the Integer at the given index, or the default if it does not exist or is the wrong type.
    • getLong

      public long getLong(int key)
      Returns the Long at the given index, or 0 if it does not exist or is the wrong type.
    • getLong

      public long getLong(int key, long default_)
      Returns the Long at the given index, or the default if it does not exist or is the wrong type.
    • getNumber

      public Number getNumber(int key)
      Returns the Number at the given index, or null if it does not exist or is the wrong type.
    • getNumber

      public Number getNumber(int key, Number default_)
      Returns the Number at the given index, or the default if it does not exist or is the wrong type.
    • getObject

      public JsonObject getObject(int key)
      Returns the JsonObject at the given index, or null if it does not exist or is the wrong type.
    • getObject

      public JsonObject getObject(int key, JsonObject default_)
      Returns the JsonObject at the given index, or the default if it does not exist or is the wrong type.
    • getString

      public String getString(int key)
      Returns the String at the given index, or null if it does not exist or is the wrong type.
    • getString

      public String getString(int key, String default_)
      Returns the String at the given index, or the default if it does not exist or is the wrong type.
    • has

      public boolean has(int key)
      Returns true if the array has an element at that index (even if that element is null).
    • isBoolean

      public boolean isBoolean(int key)
      Returns true if the array has a boolean element at that index.
    • isNull

      public boolean isNull(int key)
      Returns true if the array has a null element at that index.
    • isNumber

      public boolean isNumber(int key)
      Returns true if the array has a number element at that index.
    • isString

      public boolean isString(int key)
      Returns true if the array has a string element at that index.