json-expected-stream

0.2.2 • Public • Published
# json-expected-stream

Filter stream that enforces only selected JSON object string elements exist and that they exist in order.

Install

npm install json-expected-stream

Usage

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"}

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.2
    1
    • latest

Version History

Package Sidebar

Install

npm i json-expected-stream

Weekly Downloads

1

Version

0.2.2

License

MIT

Last publish

Collaborators

  • angleman