The following is a quick guide on how to format json data into ndjson and import the resulting data into sanity studio using the sanity cli.
Sanity is a structured content platform that is incredibly fast and flexible.
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’
Get jq
here: https://stedolan.github.io/jq/
cat test.json | jq -c '.[]' > test.ndjson
User the above code to convert and save JSON files in NDJSON format.
Note: You need to have the sanity CLI installed prior to running command.
sanity dataset import <file.ndjson> <targetDataset>