#where
Returns the elements of an array that match a predicate.
#where(array, @x: predicate)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
array |
path | array |
The source array. |
predicate |
lambda |
Returns true to keep an element. |
Returns
Section titled “Returns”array
Examples
Section titled “Examples”Filter objects
Section titled “Filter objects”{ "some": { "complexArray": [ { "some": { "path": 5 } }, { "some": { "path": 30 } } ] }}{ "filteredData": "#valueOf($.some.complexArray)->#where(@x: @x.some.path < 10)"}{ "filteredData": [ { "some": { "path": 5 } } ]}