JQ group_by example

Group an array of JSON objects by a field with jq group_by(). Interactive example that buckets records by a shared key and collects their values.

The jq expression

.calls | group_by(.route) | map({key: .[0].route, value: map(.path)})

group_by(path) splits an array into sub-arrays whose elements share the same value at path. Because the result is a list of groups, you usually map over it to build a summary object per group. Here we group API calls by .route and, for each group, emit an object with the route as key and the list of request paths as value.