Interface JsonArray
- All Superinterfaces:
JsonNode
Interface that represents a JSON array.
-
Method Summary
Modifier and TypeMethodDescriptionAdds aJsonNodeto the end of this array.clear()Clears all values in the array.elements()AStreamthat iterates all elements in the array.get(int index) Gets theJsonNodeat the given index of the array.booleanhas(int index) Determines if the array contains a value for the given index.default booleanisArray()remove(int index) Removes theJsonNodeat the specified index of the array.Replaces theJsonNodeat the specified index with a new node.intsize()Gets the size of the array.
-
Method Details
-
isArray
default boolean isArray()Description copied from interface:JsonNode -
add
Adds aJsonNodeto the end of this array. -
clear
JsonArray clear()Clears all values in the array.- Returns:
- The updated
JsonArrayobject.
-
elements
AStreamthat iterates all elements in the array.- Returns:
Streamfor all elements in the array.
-
get
Gets theJsonNodeat the given index of the array.- Parameters:
index- Index of the array.- Returns:
- The
JsonNodeat the given index of the array if set, otherwisenull. - Throws:
IndexOutOfBoundsException- Ifindexis less than0or greater thansize().
-
has
boolean has(int index) Determines if the array contains a value for the given index.If
indexis less than0or greater than equal tosize()falseis returned.- Parameters:
index- Index of the array.- Returns:
- Whether the array contains a value for the index.
-
remove
Removes theJsonNodeat the specified index of the array.- Parameters:
index- Index of the array.- Returns:
- The
JsonNodeat the given index of the array. - Throws:
IndexOutOfBoundsException- Ifindexis less than0or greater thansize().
-
set
Replaces theJsonNodeat the specified index with a new node.- Parameters:
index- Index of the array.jsonNode- The newJsonNodevalue to set.- Returns:
- The old
JsonNodevalue at the given index of the array. - Throws:
IndexOutOfBoundsException- Ifindexis less than0or greater thansize().
-
size
int size()Gets the size of the array.- Returns:
- The size of the array.
-