# big-json-streamer

> Parse big json data using streams

Latest version **1.0.6** (published 2015-07-01) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install big-json-streamer
pnpm add big-json-streamer
yarn add big-json-streamer
bun add big-json-streamer
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2015-07-01 |
| First published | 2015-06-10 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Facundo Crego |
| Maintainers | facka |
| Keywords | json, parser, streams, bigdata |

## Links

- npm: https://www.npmjs.com/package/big-json-streamer
- Repository: https://github.com/facka/big-json-streamer
- Issues: https://github.com/facka/big-json-streamer/issues
- npm.io page: https://npm.io/package/big-json-streamer

## 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

- 1.0.6 (latest) — 2015-07-01
- 1.0.5 — 2015-06-23
- 1.0.4 — 2015-06-18
- 1.0.3 — 2015-06-10
- 1.0.2 — 2015-06-10
- 1.0.1 — 2015-06-10
- 0.0.0 — 2015-06-10

## README

# big-json-streamer  [![Coverage Status](https://coveralls.io/repos/facka/big-json-streamer/badge.svg)](https://coveralls.io/r/facka/big-json-streamer)
[![PayPayl donate button](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9EZ9FXTKK44W "Donate once-off to this project using Paypal")
[![Join the chat at https://gitter.im/facka/big-json-streamer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/facka/big-json-streamer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![NPM](https://nodei.co/npm/big-json-streamer.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/big-json-streamer/)


NodeJS: Parse big JSON files using streams.

Parse big files with the following format streaming to the output the choosen jsons:


    {
      "collection1" : [
          {"key1": "value",
           "key2": "value"
          },
          {"key1": "value",
           "key2": "value"
          },
          ...
      ],
      "collection2" : [
          {"key1": "value",
           "key2": "value"
          },
          {"key1": "value",
           "key2": "value"
          },
          ...
      ],
    }
    
## Streams JSON one by one saying from which collection is the json node

```javascript
/**
* Return the string that will be pushed to the writable stream. If you want to ignore the json node just return null.
*/
jsonParser.onJson(function(json, string, collection) {
        return string;
});
```
    

##Example

```javascript
var fs = require('fs');
var jsonParser = require('big-json-streamer');

var file = process.argv[2];
var output = file ? fs.createWriteStream(file) : process.stdout;
var input = fs.createReadStream('./test.json');

//Set readableStream from where read the json
jsonParser.setInput(input);
//Set writableStream from where write the json
jsonParser.setOutput(output);
//Set callback to get each json found
jsonParser.onJson(function(json, string, collection) {

//    Filter json accessing to the properties and return the string value if you want to include it to the result or null if you want to discard it.

//    if (json.type === 'entity') {
        return string;
//    }

});

//Set callback to do something when the big json finish.
jsonParser.onEnd(function() {
    console.log('End!');
});

//Start the parsing
jsonParser.parse();

```

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