var ldj = require('ldjson-stream')
returns a transform stream that accepts newline delimited json and emits objects
example newline delimited json:
data.txt
:
{"foo": "bar"}
{"hello": "world"}
usage:
fs.createReadStream('data.txt')
.pipe(ldj.parse())
.on('data', function(obj) {
// obj is a javascript object
})
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()
BSD