Interface JsonArray

All Superinterfaces:
JsonNode

public interface JsonArray extends JsonNode
Interface that represents a JSON array.
  • Method Details

    • isArray

      default boolean isArray()
      Specified by:
      isArray in interface JsonNode
      Returns:
      True if this JsonNode is an instance of JsonArray.
    • add

      JsonArray add(JsonNode jsonNode)
      Adds a JsonNode to the end of this array.
      Parameters:
      jsonNode - The JsonNode to add to the array.
      Returns:
      The updated JsonArray object.
    • clear

      JsonArray clear()
      Clears all values in the array.
      Returns:
      The updated JsonArray object.
    • elements

      Stream<JsonNode> elements()
      Returns:
      Stream for all elements in the array.
    • get

      JsonNode get(int index)
      Gets the JsonNode at the given index of the array.
      Parameters:
      index - Index of the array.
      Returns:
      The JsonNode at the given index of the array if set, otherwise null.
      Throws:
      IndexOutOfBoundsException - If index is less than 0 or greater than size().
    • has

      boolean has(int index)
      Determines if the array contains a value for the given index.

      If index is less than 0 or greater than equal to size() false is returned.

      Parameters:
      index - Index of the array.
      Returns:
      Whether the array contains a value for the index.
    • remove

      JsonNode remove(int index)
      Removes the JsonNode at the specified index of the array.
      Parameters:
      index - Index of the array.
      Returns:
      The JsonNode at the given index of the array.
      Throws:
      IndexOutOfBoundsException - If index is less than 0 or greater than size().
    • set

      JsonNode set(int index, JsonNode jsonNode)
      Replaces the JsonNode at the specified index with a new node.
      Parameters:
      index - Index of the array.
      jsonNode - The new JsonNode value to set.
      Returns:
      The old JsonNode value at the given index of the array.
      Throws:
      IndexOutOfBoundsException - If index is less than 0 or greater than size().
    • size

      int size()
      Returns:
      The size of the array.