ndjson-to-file
✓ Published0🌍 Public
11wheel
Last edited Jan 21, 2017
Created on Jan 21, 2017
This example explores the challenge of writing large JSON datasets to disk. It demonstrates a failing workaround that serializes data in chunks to multiple files, and two broken attempts at using streaming libraries. The code uses `JSON.stringify` with `fs.writeFileSync` for the chunked approach, and attempts to use the `ndjson` and `JSONStream` libraries with `fs.createWriteStream` and piping for streaming output. The example highlights the difficulty of handling big data blobs that crash `JSON.stringify` and the struggle to implement a proper streaming solution.
AI-generated descriptionTrying to save a big blob of JSON that crashes JSON.stringify. Spliting into smaller arrays and saving works, but I can't figure out how to use a stream.