Skip to content

Instantly share code, notes, and snippets.

@maxrodrigo
Created January 7, 2019 09:29
Show Gist options
  • Save maxrodrigo/5f1ea7663b066bc24c4e769e2010cf73 to your computer and use it in GitHub Desktop.
Save maxrodrigo/5f1ea7663b066bc24c4e769e2010cf73 to your computer and use it in GitHub Desktop.
Convert csv to json with jq
jq --slurp --raw-input --raw-output \
'split("\n") | .[1:] | map(split(",")) |
map({"id": .[0],
"example": .[1],
"attribute": .[2]})' \
example.csv > example.json
@sysdef
Copy link

sysdef commented Dec 18, 2020

I get an additionale "null" part here.

{ "id": null, "example": null, "attribute": null }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment