Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Warning</strong>: Since this answer was written, the author of the JSONStream library <a href="https://github.com/dominictarr/JSONStream/commit/97d973ac59d0e58748cec98ea87aae36e057d368" rel="nofollow noreferrer">removed the emit root event functionality</a>, apparently to fix a memory leak. Future users of this library, you can use the 0.x.x versions if you need the emit root functionality. </p> <p><strong>Below is the unmodified original answer</strong>:</p> <p>From the <a href="https://github.com/dominictarr/JSONStream#jsonstreamparsepath" rel="nofollow noreferrer">readme</a>:</p> <blockquote> <h2>JSONStream.parse(path)</h2> <p><code>path</code> should be an array of property names, RegExps, booleans, and/or functions. Any object that matches the path will be emitted as <code>'data'</code>.</p> <p>A <code>'root'</code> event is emitted when all data has been received. The <code>'root'</code> event passes the root object &amp; the count of matched objects.</p> </blockquote> <p>In your case, since you want to get back the JSON objects as opposed to specific properties, you will be using the <code>'root'</code> event and you don't need to specify a path.</p> <p>Your code might look something like this:</p> <pre><code>var fs = require('fs'), JSONStream = require('JSONStream'); var stream = fs.createReadStream('data.json', {encoding: 'utf8'}), parser = JSONStream.parse(); stream.pipe(parser); parser.on('root', function (obj) { console.log(obj); // whatever you will do with each JSON object }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload