Interface JsonArray
- All Superinterfaces:
JsonNode
Interface that represents a JSON array.
-
Method Summary
Modifier and TypeMethodDescriptionAdds aJsonNode
to the end of this array.clear()
Clears all values in the array.elements()
get
(int index) Gets theJsonNode
at the given index of the array.boolean
has
(int index) Determines if the array contains a value for the given index.default boolean
isArray()
remove
(int index) Removes theJsonNode
at the specified index of the array.Replaces theJsonNode
at the specified index with a new node.int
size()
-
Method Details
-
isArray
default boolean isArray() -
add
Adds aJsonNode
to the end of this array. -
clear
JsonArray clear()Clears all values in the array.- Returns:
- The updated
JsonArray
object.
-
elements
- Returns:
Stream
for all elements in the array.
-
get
Gets theJsonNode
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, otherwisenull
. - Throws:
IndexOutOfBoundsException
- Ifindex
is less than0
or greater thansize()
.
-
has
boolean has(int index) Determines if the array contains a value for the given index.If
index
is less than0
or greater than equal tosize()
false
is returned.- Parameters:
index
- Index of the array.- Returns:
- Whether the array contains a value for the index.
-
remove
Removes theJsonNode
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
- Ifindex
is less than0
or greater thansize()
.
-
set
Replaces theJsonNode
at the specified index with a new node.- Parameters:
index
- Index of the array.jsonNode
- The newJsonNode
value to set.- Returns:
- The old
JsonNode
value at the given index of the array. - Throws:
IndexOutOfBoundsException
- Ifindex
is less than0
or greater thansize()
.
-
size
int size()- Returns:
- The size of the array.
-