Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manidlou/concatjson
concatenated JSON streaming parser/serializer for node.js
https://github.com/manidlou/concatjson
concatenated-json nodejs serializer stream streaming-parser
Last synced: 2 months ago
JSON representation
concatenated JSON streaming parser/serializer for node.js
- Host: GitHub
- URL: https://github.com/manidlou/concatjson
- Owner: manidlou
- License: mit
- Created: 2016-11-24T09:34:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-12T14:50:42.000Z (5 months ago)
- Last Synced: 2024-10-12T18:14:25.247Z (3 months ago)
- Topics: concatenated-json, nodejs, serializer, stream, streaming-parser
- Language: JavaScript
- Size: 69.3 KB
- Stars: 9
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
concatjson
==========[![npm](https://img.shields.io/npm/v/concatjson.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/concatjson) [![travis](https://img.shields.io/travis/manidlou/concatjson/master.svg)](https://travis-ci.org/manidlou/concatjson)
_Inspired by [https://github.com/maxogden/ndjson](https://github.com/maxogden/ndjson)_
`concatjson` is [concatenated JSON](https://en.wikipedia.org/wiki/JSON_Streaming) streaming parser/serializer for [Node.js](https://nodejs.org).
Install
-------`npm i concatjson`
Usage
-----**concatjson.parse()**
* `@return` {[Stream.Transform](https://nodejs.org/api/stream.html#stream_class_stream_transform)} a Transform stream
parses concatenated JSON stream and emits javascript objects.
_`somefile (contains concatenated JSON objects)`_
```js
{"foo":"bar"}{"qux":"corge"}{"baz":{"waldo":"thud"}}
``````js
const fs = require('fs')
const cj = require('concatjson')fs.createReadStream('./somefile')
.pipe(cj.parse())
.on('error', err => console.error(err))
.on('data', obj => {
// obj is a js object
})
```
**concatjson.serialize()**alias: `concatjson.stringify()`
* `@return` {[Stream.Transform](https://nodejs.org/api/stream.html#stream_class_stream_transform)} a Transform stream
accepts objects and emits stringified JSON objects.
```js
const cj = require('concatjson')
const ser = cj.serialize()
ser.write({foo: 'bar'})
ser.end()
ser.on('data', dat => {
// dat is stringified JSON
})
```License
-------MIT