New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fast-json-parser

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-json-parser

Fast incremental json parser

latest
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

fast-json-parser

Fast incremental (streaming) JSON parser for node

performance

At the moment, its about 3 times slower than buffering a node stream then parsing it with JSON.parse

However, its about 3 times faster than oboe.js as well.

Currently works on valid JSON, however it also accepts invalid JSON.

Check out the benchmarks in the perf dir

$ node perf/big-bench.js
testJSONParse: 858.689ms
testOboe: 7263.890ms
testFastJsonParser: 2529.559ms

usage example

A static convenience method is available for node streams:

import { Parser } from "fast-json-parser";

async function test() {
  let result = await Parser.parseStream(stream);
  console.log(result);
}

Or you can use the raw API:

import { Parser } from "fast-json-parser";

function parseStream(stream) {
  return new Promise(resolve => {
    let p = new Parser();
    p.init();
    stream.on("data", data => p.push(data));
    stream.on("end", () => resolve(p.value));
  });
}

build

Install typescript then simply run tsc from the base dir

todo

  • moar perf! (buffer based string parser in node?)

forbid:

  • forbid leading zero in numbers unless followed by dot
  • forbid dot at end of number
  • forbid comma before end of array and objects

test:

  • end with unicode escape sequence
  • add buffer splitting to fuzzer

license

MIT

Keywords

json

FAQs

Package last updated on 12 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts