Using array predicates
An array predicate allows you to filter items by their position in the current context.
This predicate is used after a location step, in square brackets, to return one or more
items based on their index. The table below describes the syntax to use.
Syntax | Description | Examples |
---|---|---|
[index] | Returns the item with the specified index. |
|
[index:] | Returns items whose index is equal to or greater than the specified index. |
|
[:index] | Returns items whose index is equal to or lesser than the specified index. Information noteNote: When used with a negative number, this syntax subtracts the specified
value from the size of the array and compares the result to the indexes in the array.
For example, for an array with 5 items, [:-2] returns all items whose
index is lesser than or equal to 5-2, so it returns indexes 0 to 3
and only ignores the last item, which has the index 4.
|
|
[start_index:end_index] | Returns items between the first index and the second index. Both the start index and the end indexes are included in the result. |
|
[*] | Returns all items in the current context. | .customer[*] returns all items in the customer array. |