json-doc-stream

1.1.1 • Public • Published

json-doc-stream

Parse streams of JSON documents.

A simple wrapper for jsonparse to efficiently parse a stream of multple JSON documents emitting events as each document completes containing the parsed data. This library handles most corner cases involved in streaming JSON documents over multiple lines. However if you have simple uses cases and can stream JSON documents as single lines then you may get more mileage out of simple-json-doc-stream.

Install

npm install json-doc-stream

Usage

const JSONDocStream = require('json-doc-stream');
 
const stream = new JSONDocStream();
 
stream.on('parsed', parsed => {
  // handle the parsed JSON document
  // could be an object, array, string,
  // number, boolean or null
});
 
stream.on('error', error => {
  // handle parse errors
});
 
stream.write(JSONdata);
 
// or
 
readableStream.pipe(stream);

Readme

Keywords

Package Sidebar

Install

npm i json-doc-stream

Weekly Downloads

4

Version

1.1.1

License

ISC

Unpacked Size

3.52 kB

Total Files

5

Last publish

Collaborators

  • pghalliday