countBy
Count elements in an array that match a predicate.
array(required): the array to countpredicate(required): lambda(element) -> boolean
bash
echo '{"orders": [{"status": "ACTIVE"}, {"status": "CLOSED"}, {"status": "ACTIVE"}]}' \
| utlx -e 'countBy($input.orders, (o) -> o.status == "ACTIVE")'
# 2utlx
let active = filter($input.orders, (o) -> o.status == "ACTIVE")
{
activeCount: count(active),
closedCount: countBy($input.orders, (o) -> o.status == "CLOSED"),
activeNames: map(active, (o) -> o.name)
}