Skip to content

Instantly share code, notes, and snippets.

@erichsu
Created August 14, 2018 15:10
Show Gist options
  • Save erichsu/1f149917cd48bce26bb377c7bf0ae04c to your computer and use it in GitHub Desktop.
Save erichsu/1f149917cd48bce26bb377c7bf0ae04c to your computer and use it in GitHub Desktop.
jq-to-csv
# e.g.
# echo '[{"a":1, "b":2}, {"a":3, "b":4}]' | jq '.[]'
jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment