You can transform an existing collection by selecting a subset based on filtering criteria, which results in a new collection.
<Collection>.?[<Filter Criteria
Expression>]
becomes a new collection.
In addition to returning a filtered collection, you can extract the first or last entry in a collection matching the filter criteria.
<Collection>.^[<Filter Criteria
Expression>]
returns the first element matching the
filter criteria.
<Collection>.$[<Filter Criteria
Expression>]
returns the last element matching the filter
criteria.
Selection | Input | Output |
---|---|---|
From an array or collection of numbers, select only the even numbers |
|
|
From an array or collection of numbers, select the first even number |
|
|
From an array or collection of numbers, select the last even number |
|
|
For the following input data model, the table following the data model describes possible selections.
{
"user": {
"contacts": [
{
"info": "user01@test.com",
"primary": false,
"type": "email"
},
{
"info": 9876512345,
"primary": true,
"type": "phone"
},
{
"info": 9876511111,
"primary": false,
"type": "phone"
}
]
}
}
Selection | Input | Output |
---|---|---|
Select all contact info of type |
|
|
Select the first primary contact info |
|
|