ldjson-stream
streaming line delimited json parser + serializer
Last updated 10 years ago by maxogden .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ npm install ldjson-stream 
SYNC missed versions from official npm registry.

ldjson-stream

streaming line delimited json parser + serializer

NPM

usage

var ldj = require('ldjson-stream')

ldj.parse()

returns a transform stream that accepts newline delimited json and emits objects

example newline delimited json:

data.txt:

{"foo": "bar"}
{"hello": "world"}

If you want to discard non-valid JSON messages, you can call ldj.parse({strict: false})

usage:

fs.createReadStream('data.txt')
  .pipe(ldj.parse())
  .on('data', function(obj) {
    // obj is a javascript object
  })

ldj.serialize()

returns a transform stream that accepts json objects and emits newline delimited json

example usage:

var serialize = ldj.serialize()
serialize.on('data', function(line) {
  // line is a line of stringified JSON with a newline delimiter at the end
})
serialize.write({"foo": "bar"})
serialize.end()

license

BSD

Current Tags

  • 1.2.1                                ...           latest (10 years ago)

5 Versions

  • 1.2.1                                ...           10 years ago
  • 1.2.0                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.0.1                                ...           11 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (1)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE