jq 'to_entries[] | "\(.key): \(.value)"' object.json

Category: Data Science & Analysis

jq 'to_entries[] | "\(.key): \(.value)"' object.json

Print each key and value as one line

to_entries converts an object into an array of key and value pairs, and .[] streams them. The string interpolation \(.key) and \(.value) injects each pair into a formatted line. The result is one key and value pair per line. This is the standard jq idiom for flattening an object into grep-friendly text.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.