Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nisaacson/json-parser-stream
Parse a readable stream of json strings into javascript objects
https://github.com/nisaacson/json-parser-stream
Last synced: about 1 month ago
JSON representation
Parse a readable stream of json strings into javascript objects
- Host: GitHub
- URL: https://github.com/nisaacson/json-parser-stream
- Owner: nisaacson
- Created: 2014-01-08T15:29:35.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-09T19:59:34.000Z (almost 11 years ago)
- Last Synced: 2024-10-11T00:47:16.383Z (about 1 month ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSON Parser Stream
Parse a readable stream of json strings into javascript objects
[![NPM](https://nodei.co/npm/json-parser-stream.png)](https://nodei.co/npm/json-parser-stream/)
[![Build Status](https://travis-ci.org/nisaacson/json-parser-stream.png)](https://travis-ci.org/nisaacson/json-parser-stream)
[![Dependency Status](https://david-dm.org/nisaacson/json-parser-stream/status.png)](https://david-dm.org/nisaacson/json-parser-stream)
[![Code Climate](https://codeclimate.com/github/nisaacson/json-parser-stream.png)](https://codeclimate.com/github/nisaacson/json-parser-stream)# Installation
```bash
npm install -S json-parser-stream
```# Usage
Create an instance of linestream and pipe a readable stream into that instance
```javascript
var JSONParserStream = require('json-parser-stream')
// parser is an instance of require('stream').Transform
var opts = {
highWaterMark: 2
}
var parser = new JSONParserStream(opts) // opts is optionalvar readStream = {} // a stream of single json strings per data event
var parser = readStream.pipe(splitter)
parser.on('data', function(chunk) {
console.dir(chunk) // no line breaks here :)
})
parser.on('finish', function() {
console.log('finish event called, all json items read')
})
```