jsonstream

<a href=”http://browsenpm.org/package/jsonstream”>JSONStream</a> (GitHub: <a href=”https://github.com/dominictarr/JSONStream”>dominictarr/JSONStream</a>, License: Apache) is a module by <a href=”https://github.com/dominictarr”>Dominic Tarr</a> for streaming <code>JSON.parse</code> and <code>JSON.stringify</code>.
<pre><code>npm install jsonstream
</code></pre>
<h2 id=”usage”>Usage</h2>
<pre><code>var request = require(‘request’),
JSONStream = require(‘JSONStream’),
es = require(‘event-stream’)
;

var parser = JSONStream.parse([‘rows’, true]),
req = request({url: ‘http://isaacs.couchone.com/registry/_all_docs’}),
logger = es.mapSync(function (data) {
console.error(data);
return data;
})

request({url: ‘http://isaacs.couchone.com/registry/_all_docs’})
.pipe(JSONStream.parse(‘rows.*’))
.pipe(es.mapSync(function (data) {
console.error(data);
return data;
}));
</code></pre>
<img class=”hide-on-mobile” src=”http://npmawesome.com/images/posts/json.svg” />I like the idea behind streaming JSON alot because you don’t have to wait for the whole document to come down the pipe, especially if it’s very large. It can also integrate with <a href=”http://gulpjs.com/”>gulp.js</a> very nicely. The really cool thing for me is that you can react to specific nodes in the data structure vs having to seek them out and loop over them manually.

Are you dealing with large JSON structures on your project?
<div class=”social-box”>
<div class=”yashare-auto-init b-share_theme_counter” data-yasharelink=”http://npmawesome.com/posts/2014-02-12-jsonstream” data-yasharel10n=”en” data-yasharequickservices=”facebook,twitter,gplus” data-yasharetheme=”counter” data-yasharetype-off=”small”></div>
</div>