Skip to content

Instantly share code, notes, and snippets.

@gigkokman
Created March 17, 2020 01:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gigkokman/bf3b305f1073c176403958628419bb2b to your computer and use it in GitHub Desktop.
Save gigkokman/bf3b305f1073c176403958628419bb2b to your computer and use it in GitHub Desktop.
Export json to csv with header via jq script
echo '{"a":"aa", "b":"bb"}' | jq -r -s '. | (map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment