TIL using jq to turn JSON into CSV
POSTED ON:
I've been learning about jq recently.
jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that
sed
,awk
,grep
and friends let you play with text.
One of the benefits is turning a JSON response into CSV.
jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv'
Via https://stackoverflow.com/a/32965227
Related TILs
Tagged: terminal