json-expected-stream
v0.2.2
Published
Filter stream that enforces only selected JSON object string elements exist and that they exist in order
Maintainers
Readme
Filter stream that enforces only selected JSON object string elements exist and that they exist in order.
Install
npm install json-expected-streamUsage
Sample logfile.json line:
{"ip": "198.55.125.23", "timestamp":"2014-02-24 10:29:42", "url": "http:\/\/somedomain.com"}var fs = require('fs');
var logstream = fs.createReadStream('logfile.json');
var split = new require('split')();
var JsonExpectedStream = require('json-expected-stream');
var expectedStream = new JsonExpectedStream([ "url", "city", "timestamp" ]);
logstream
.pipe(split)
.pipe(expectedStream)
.pipe(process.stdout) // {"url": "http:\/\/somedomain.com", "city": null, "timestamp":"2014-02-24 10:29:42"}