Skip to content

angleman/json-expected-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# 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

About

Filter stream that enforces only selected JSON object strings exist and that they do exist

Resources

License

Stars

Watchers

Forks

Packages

No packages published