# parse-large-json

> Parse large JSON strings without blockage by parsing chunks asynchronously

Latest version **1.2.0** (published 2017-05-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install parse-large-json
pnpm add parse-large-json
yarn add parse-large-json
bun add parse-large-json
```

## 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.2.0 |
| Published | 2017-05-19 |
| First published | 2017-04-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Marcus Besjes |
| Maintainers | vigour-io |
| Keywords | JSON, parse, async, asynchronous, actually, asynchronous |

## Links

- npm: https://www.npmjs.com/package/parse-large-json
- Repository: https://github.com/vigour-io/parse-large-json
- Homepage: https://github.com/vigour-io/parse-large-json#readme
- Issues: https://github.com/vigour-io/parse-large-json/issues
- npm.io page: https://npm.io/package/parse-large-json

## Dependencies (1)

- [bubleify](https://npm.io/package/bubleify.md) 0.5.1

## 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.2.0 (latest) — 2017-05-19
- 1.1.1 — 2017-05-19
- 1.1.0 — 2017-05-17
- 1.0.2 — 2017-04-17
- 1.0.1 — 2017-04-15
- 1.0.0 — 2017-04-15

## README

# Parse large JSON

Parse JSON in chunks so that weak devices can still function. e.g. allow mobile phones to load decently sized JSON objects without blocking user interaction.

## Install

#### npm
```
npm i parse-large-json --save
```

#### yarn
```
yarn add parse-large-json
```

## Usage

```JavaScript
const parse = require('parse-large-json')

const hugeJSONstring = '{"big":true}' // no whitespaces allowed!
const maxChunkSize = 100e3 

parse(hugeJSONstring, maxChunkSize).then(({val, rest}) => {
  if (rest) {
    throw Error('wicked string?')
  }
  console.log('parsed it!', val)
})

```

## Workings

`parse-large-json` works by looking ahead in the string up to `maxChunkSize`, and determining if the first thing it sees there is an Object it can parse synchronously using `JSON.parse`. If this is not the case, it starts reading the string, parsing "primitives" synchronously, but passing any Object handling to the next tick using a Promise.

This way, the user can control the balance between 
- large amount of small chunks (less blockage, more promises, more time)
- small amount of large chunks (more blocakge, less promises, less time)

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