json-stream-es is a modern JavaScript library that provides a streaming alternative to JSON.parse() and JSON.stringify(). It is published as an ECMASc

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-06-11 13:30:05

json-stream-es is a modern JavaScript library that provides a streaming alternative to JSON.parse() and JSON.stringify(). It is published as an ECMAScript Module (ESM) and uses the new Streams API (in particular TransformStreams), and thus should work in the browser, in Node.js and in any other modern JavaScript environment. json-stream-es also supports various types of JSON streaming, in particular generating/consuming multiple JSON documents separated by newlines (JSONL), record separators (JSON-seq) or no delimiter.

When implementing a web service in the backend (for example a REST API), streaming JSON has the advantage that the data arrives to the user faster (because the web service doesn’t have to wait for all data to be loaded from the database before it can start sending it), and that memory consumption is greatly reduced (because the service only needs to keep small chunks of the data in memory before passing it on to the user).

When consuming a web service from the frontend, streaming JSON has the advantage that you can display the partial data as it loads, and that memory consumption is reduced if you only intend to consume parts of the retrieved data.

Leave a Comment