Interface JsonOperations.JsonArraySpec
- All Superinterfaces:
JsonOperations.PathSpec<JsonOperations.JsonArraySpec>
- Enclosing interface:
JsonOperations<K>
public static interface JsonOperations.JsonArraySpec
extends JsonOperations.PathSpec<JsonOperations.JsonArraySpec>
Specification for JSON array operations bound to a particular
key.
All commands invoked through this interface operate on a JSON path defaulting to the
document root ($).
- Since:
- 4.2
- Author:
- Mark Paluch, Yordan Tsintsov, Moritz Halbritter
-
Method Summary
Modifier and TypeMethodDescriptionAppend the givenvaluesto the JSON array at the configured path.append(Collection<? extends Object> values) Append the givenvaluesto the JSON array at the configured path.index(int index) Select an array element by itsindexfor subsequent operations.Return the first index ofvaluewithin the JSON array at the configured path.length()Return the length of the JSON array at the configured path.trim(int start, int end) Trim the JSON array to the inclusive range betweenstartandend.Methods inherited from interface JsonOperations.PathSpec
path, root
-
Method Details
-
append
-
append
Append the givenvaluesto the JSON array at the configured path.- Parameters:
values- the values to append, must not be empty or null.- Returns:
- the new array length for each matching path.
- See Also:
-
length
-
trim
Trim the JSON array to the inclusive range betweenstartandend.- Parameters:
start- the index of the first element to keep.end- the index of the last element to keep. Negative values count from the end.- Returns:
- the new array length for each matching path.
- See Also:
-
indexOf
Return the first index ofvaluewithin the JSON array at the configured path.- Parameters:
value- the value to find.- Returns:
- a list where each element contains the index of the first occurrence of the value,
-1if not found, or null if the matched value is not an array. Returns an empty list if the path does not match any value. - See Also:
-
index
Select an array element by itsindexfor subsequent operations.- Parameters:
index- the array index to operate on.- Returns:
- a spec for index-based array operations.
-