Skip to content

Instantly share code, notes, and snippets.

@soltrinox
Forked from bzerangue/json-to-ndjson.md
Created October 27, 2021 22:23
Show Gist options
  • Save soltrinox/8406a2c91ba21762ba6a80bc6ef255a1 to your computer and use it in GitHub Desktop.
Save soltrinox/8406a2c91ba21762ba6a80bc6ef255a1 to your computer and use it in GitHub Desktop.
JSON to NDJSON

NDJSON is a convenient format for storing or streaming structured data that may be processed one record at a time.

  • Each line is a valid JSON value
  • Line separator is ‘\n’

1. Convert JSON to NDJSON?

cat test.json | jq -c '.[]' > testNDJSON.json

With this simple line of code, you can convert and save files in NDJSON format.

Note: jq is a lightweight and flexible command-line JSON processor.
https://stedolan.github.io/jq/

Source: https://medium.com/datadriveninvestor/json-parsing-error-how-to-load-json-into-bigquery-successfully-using-ndjson-2b7d94616bcb

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