# newline-json

> New-line separated JSON streaming

Latest version **0.1.1** (published 2014-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install newline-json
pnpm add newline-json
yarn add newline-json
bun add newline-json
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2014-05-29 |
| First published | 2013-11-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | joaojeronimo |
| Keywords | JSON, stream, streams2, new-line |

## Links

- npm: https://www.npmjs.com/package/newline-json
- Repository: https://github.com/CrowdProcess/newline-json
- Issues: https://github.com/CrowdProcess/newline-json/issues
- npm.io page: https://npm.io/package/newline-json

## Dependencies (1)

- [stream2buffer](https://npm.io/package/stream2buffer.md) 0.0.4

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.1 (latest) — 2014-05-29
- 0.0.4 — 2014-04-04
- 0.0.3 — 2014-01-30
- 0.0.2 — 2013-12-10
- 0.0.1 — 2013-11-13

## README

# newline-json

Just like [JSONStream](https://github.com/dominictarr/JSONStream),
but instead of streaming valid JSON arrays, it streams new-line separated
JSON objects.

**It requires browserify 3.x from 0.1 upwards, versions 0.0.x are compatible with browserify 2.x.**

## Example

If you have a readable stream like

```js
var n = 100;
var nlj = new Readable();
nlj._read = function _read () {
  if (n--)
    nlj.push('{"this":"is","js":"on"}\n'); // new-line separated JSON!
  else
    nlj.push(null);
}
return nlj;
```

you can pipe it to the parser

```js
var Parser = require('newline-json').Parser;
var parser = new Parser();
nlj.pipe(parser);
```

what comes out of the parser will be the the objects you piped to it, parsed.
You can pipe those again to the stringifier:

```js
var Stringifier = require('newline-json').Stringifier;
var stringifier = new Stringifier();
parser.pipe(stringifier);
```

And if you have nothing better to do today, be sure to try

```js
parser.pipe(stringifier);
stringifier.pipe(parser);
```

## Why ?

Couldn't find one on npm that used the
[`Transform`](http://nodejs.org/api/stream.html#stream_class_stream_transform_1),
and IMO if you don't need to parse complex object paths, then you'd be better off
using a new-line separated JSON. Also, it's probably much easier to write parsers
like this in other languages and environments, which is good if your stack is
not 100% node.js.

---
_Source: https://npm.io/package/newline-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
