Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Filter stream that enforces only selected JSON object strings exist and that they do exist
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
CHANGE_LOG.md
Gruntfile.js
LICENSE
README.md
index.js
logo.jpg
package.json

README.md

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

Something went wrong with that request. Please try again.