https://github.com/evanw/uint8array-json-parser
JSON.parse() for Uint8Array to get around the maximum string size in V8
https://github.com/evanw/uint8array-json-parser
Last synced: about 2 months ago
JSON representation
JSON.parse() for Uint8Array to get around the maximum string size in V8
- Host: GitHub
- URL: https://github.com/evanw/uint8array-json-parser
- Owner: evanw
- Created: 2017-08-10T08:35:27.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-05-17T19:03:19.000Z (about 3 years ago)
- Last Synced: 2025-04-11T00:12:37.206Z (about 2 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 9
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSON.parse() on Uint8Array
V8's maximum string size prevents using JSON.parse() for large JSON files.
This module exposes JSON_parse() that should behave similarly to JSON.parse() except it expects a Uint8Array instead of a String.
Using a Uint8Array lets it scale to much larger JSON files than the native JSON.parse().
It appears to be roughly 4x slower than the native implementation.## Usage
```js
var JSON_parse = require('uint8array-json-parser').JSON_parse;
var fs = require('fs');var bigFile = fs.readFileSync('./big-file.json');
var json = JSON_parse(bigFile);
console.log(json);
```## Disclaimer
I wrote this one night because I needed it.
It works fine for my use case and should be reasonably well-built (e.g. it doesn't use recursion to avoid stack overflow).
But it doesn't have test coverage, and may not do what you need it to.