ndjson
streaming newline delimited json parser + serializer
Last updated 4 years ago by finnpauls .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ndjson 
SYNC missed versions from official npm registry.

ndjson

streaming newline delimited json parser + serializer. Available as a JS API or a command line tool

NPM

usage

var ndjson = require('ndjson')

ndjson.parse(opts)

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 ndjson.parse({strict: false})

usage:

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

ndjson.serialize() / ndjson.stringify()

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

example usage:

var serialize = ndjson.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-3-Clause

Current Tags

  • 1.5.0                                ...           latest (4 years ago)

11 Versions

  • 1.5.0                                ...           4 years ago
  • 1.4.4                                ...           4 years ago
  • 1.4.3                                ...           5 years ago
  • 1.4.2                                ...           5 years ago
  • 1.4.1                                ...           5 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           6 years ago
  • 1.2.3                                ...           6 years ago
  • 1.2.2                                ...           6 years ago
  • 1.2.1                                ...           6 years ago
Maintainers (2)
Downloads
Today 87
This Week 13,252
This Month 7,893
Last Day 2,588
Last Week 13,668
Last Month 67,195
Dependencies (4)
Dev Dependencies (2)
Dependents (319)

Copyright 2014 - 2017 © taobao.org |