Pretty print JSON
Format and colorize a JSON file
cat data.json | jq '.'
More jq commands
-
cat data.json | jq '.items[] | select(.status == "Running")'Select objects where a field equals a value
-
cat data.json | jq '[.items[] | {name:.metadata.name, ns:.metadata.namespace}]'Project only specific fields into a new array
-
cat data.json | jq 'group_by(.namespace) | map({ns: .[0].namespace, count: length})'Aggregate items by a field value
-
cat data.json | jq 'del(.metadata.managedFields)'Remove a field from JSON output
-
cat data.json | jq -r '.items[].metadata.name'Raw output (-r) for scripting; one value per line