.
(Map)$
symbol.a.b.c.d
is evaluated like ((a.b).c).d
; i.e. left to right
Example
[
… ]
(Filter)$boolean()
function. If this evaluates to true
, then the item is retained in the result sequence. Otherwise it is rejected.
See Navigating JSON Arrays and Predicates for more details and examples.
^(
… )
(Order-by)Account.Order.Product^(Price)
sorts all of the products into order of increasing price (Price
is a numeric field in the Product
object).
To sort in descending order, the sort expression must be preceded by the >
symbol. For example:
Account.Order.Product^(>Price)
sorts all of the products into order of decreasing price. The <
symbol can be used to explicitly indicate ascending order, although that is the default behaviour.
Secondary (and more) sort expressions can be specified by separating them with commas (,
). The secondary expression will be used to determine order if the primary expression ranks two values the same. For example,
Account.Order.Product^(>Price, <Quantity)
orders the products primarily by decreasing price, but for products of the same price, by increasing quantity.
The sort expression(s) can be any valid JSONata expression that evaluates to a number or a string. If it evaluates to a string then the array is sorted in order of unicode codepoint.
Example
{
… }
(Reduce)*
(Wildcard)**
(Descendants)%
(Parent)%.%.
is used to access the grandparent and higher ancestors.
#
(Positional variable binding)@
(Context variable binding)$
) to a named variable. It can only be used directly following a map stage, not a filter or order-by stage.
The variable binding remains in scope for the remainder of the path expression.
Because the current context has now been explicitly bound to a named variable, this context will be carried forward to be the context of the next stage in the path.
For example, in this snippet of a path, library.loans@$l.books
, the loans array is a property of the library object and each loan will, in turn, be bound to the variable $l
.
The books array, which is also a property of the library object, will then be selected.
This operator can be used to perform data joins within a path because of its ability to do cross-referencing across objects.
Example
This performs an ‘inner join’ between objects in the loans array and objects in the books array where the ISBNs match between the structures.
Block expressions can be used to widen the scope of the data cross-referencing as shown in this example: