Skip to content

#where

Returns the elements of an array that match a predicate.

#where(array, @x: predicate)
Category Arrays and sequencesValid in Property value
Name Type Description
array path | array The source array.
predicate lambda Returns true to keep an element.

array

source.json
{
"some": {
"complexArray": [ { "some": { "path": 5 } }, { "some": { "path": 30 } } ]
}
}
transformer.json
{
"filteredData": "#valueOf($.some.complexArray)->#where(@x: @x.some.path < 10)"
}
output.json
{
"filteredData": [ { "some": { "path": 5 } } ]
}

Try it in the playground →

#select · #any