Socket
Book a DemoInstallSign in
Socket

json-parse-stream

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-parse-stream

streaming json parser

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

json-parse-stream

emits elements of a json document as they're available. similar to JSONStream, but emits everything instead of a specified path.

var fs = require('fs')
  , parse = require('json-parse-stream')

fs.createReadStream('package.json')
  .pipe(parse())
  .on('data', function(element) {
    console.log(element)
  })

/* truncated output:
...

{ type: 'string'
, value: 'json-parse-stream'
, key: 'name'
, parent: [parent object] }

...
*/

events

parse() instances are readable/writable streams.

their data events take the following form:


{ type: ['object', 'array', 'string', 'number', 'null', 'boolean']
, value: <the value represented at this node>
, key: "the key from the parent to this element" | undefined (for root objects)
, parent: <the parent node> }

you will get events for elements in order of most specific to least specific.

why not just use JSONParse?

JSONParse is awesome, but the requirement of providing a path function precludes you from asking for multiple paths at once.

As a bonus, the output of json-parse-stream will make it easy to write a wrapper for CSSauron for querying.

license

MIT

Keywords

json

FAQs

Package last updated on 14 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts