Find objects with smallest and largest values.
Section: Grouping and Aggregation
Min and max by field
bash
bash
echo '[{"name":"a","age":20},{"name":"b","age":35}]' | jq '{youngest: min_by(.age), oldest: max_by(.age)}'Explanation
`min_by()` and `max_by()` are very handy for summaries.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Grouping and Aggregation