Group by field
Count records grouped by status field
jq 'group_by(.status) | map({status: .[0].status, count: length})' data.json
More jq commands
-
jq 'flatten(1)' nested.jsonFlatten one level of nested arrays
-
jq 'INDEX(.[]; .id)' items.jsonBuild an object keyed by the id field
-
jq -s '.[0] * .[1]' base.json override.jsonDeep merge two JSON objects (right wins on conflicts)
-
jq '.config?.database?.host // "localhost"' config.jsonOptional chaining with fallback default value
-
jq 'sort_by(.timestamp) | reverse | .[0:5]' events.jsonGet 5 most recent events sorted by timestamp descending