jsonsparser

1.0.1 • Public • Published

Jsonsparser

Jsonsparser (JSONs parser) is a node module to extract JSONs from a stream.
It caches incoming data until a complete JSON can be parsed.

Compatibility

This module is written in es6, tested on node v6.2.0.

Install

npm i jsonsparser

Test

npm test

Example

const JSONsparser = require('jsonsparser')
const Readable = require('stream').Readable

// Initializing the parser
jsonsparser = new JSONsparser()
jsonsparser.on('data', (json) => {
  console.log('json', json)
})

// Initializing example source stream
input = new Readable()

// Piping source stream into the parser
input.pipe(jsonsparser)

// Sending test jsons (in parts because we can)
input.push('{"hello":')
input.push(' "world"}{"hello":')
input.push(' "world2"}')
input.push(null)

License

MIT

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i jsonsparser

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • pauloseb