JSONLines for Node.js
Parse JSONLines with Node.js.
Installation
npm install --save jsonlines
Usage
var jsonlines = var parser = jsonlines parser parser parserparserparser
var jsonlines = var stringifier = jsonlines stringifier stringifierstringifierstringifier
API
.parse([options])
Returns a transform stream that turns newline separated json into a stream of javascript values.
options
is an optional object with the keys documented below.
.stringify()
Returns a transform stream that turns javascript values into a stream of newline separated json.
Options
emitInvalidLine
If true, instead of emitting an error and cancelling the stream when an invalid line is proccessed, an invalid-line
event is emitted with the same error. This is very useful when processing text that have mixed plain text and json data.
Example:
var jsonlines = var parser = jsonlines parser parser parserparserparserparser
Output:
Got json: { test: 'This is a test!' }Got text: This is some plain textGot json: { jsonlines: 'is awesome' }