nano-json-stream-parser
Lightweight, streamed JSON parser in 748 bytes
Last updated 9 years ago by maiavictor .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install nano-json-stream-parser 
SYNC missed versions from official npm registry.

nano-json-stream-parser

A complete, pure JavaScript, streamed JSON parser in about 750 bytes (gzipped). It is similar to Oboe.js, a streaming JSON micro-library with a size of 4.8kb (gzipped). While that alone isn't much, sizes add up quickly when you stack many libs. This lib achieves a 85% size reduction, while still offering the same main functionality. Uses ES6 arrows.

Install

npm i nano-json-stream-parser

Usage

Usage is self explanatory:

const njsp = require("nano-json-stream-parser");

// Callback is called when there is a complete JSON
const parse = njsp((json) => console.log(json));

parse('[1,2,3,4]');

parse('[1,2');
parse(',3,4]');

parse("[::invalid_json_is_ignored::]");

parse('{"pos": {"x":');
parse('1.70, "y": 2.');
parse('49, "z": 2e3}}');

parse('[ "aaaa\\"abcd\\u0123\\\\aa\\/aa" ]')

Output:

[ 1, 2, 3, 4 ]
[ 1, 2, 3, 4 ]
{ pos: { x: 1.7, y: 2.49, z: 2000 } }
[ 'aaaa"abcdģ\\aa/aa' ]

Disclaimer

This library has no tests yet and could contain buggy edge-cases.

Current Tags

  • 0.1.2                                ...           latest (9 years ago)

3 Versions

  • 0.1.2                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |