Skip to content

Latest commit

 

History

History
64 lines (44 loc) · 2.34 KB

README.md

File metadata and controls

64 lines (44 loc) · 2.34 KB

jsooner

npm coverage bundle size

jsooner is a lightweight, efficient library for parsing large JSON streams.

It’s specifically designed for handling long sequences of JSON objects in a fast and memory-efficient way, without aiming to be a full-featured JSON parser.

Why jsooner?

Parsing large JSON files or continuous streams can overwhelm standard methods like JSON.parse, especially in terms of memory and speed. jsooner addresses these challenges with:

  • Efficiency: Parses JSON incrementally as data arrives, outperforming JSON.parse on streams.
  • Memory Optimization: Handles streaming data with minimal memory usage

Installation

You can install jsooner via npm:

npm install jsooner

Usage

Here's a basic example of how to use jsooner:

import { toJsonAsyncIterable } from "jsooner";

const response = await fetch("https://raw.githubusercontent.com/vnau/jsooner/refs/heads/main/examples/data/point-samples.geojson");
const features = toJsonAsyncIterable(response, { lookup: '"features"' });
for await (const feature of features) {
    console.log(feature);
}

Performance

jsooner has been benchmarked against other JavaScript parsers that support streaming, as well as the native JSON.parse method, to demonstrate its efficiency with large JSON files.

The benchmarks were conducted on a 136 MB GeoJSON file stored locally.

xychart-beta horizontal
    title "Parsing Time"
    x-axis [JSON.parse, jsooner, "streamparser/json", oboe, stream-json]
    y-axis "Time, s" 0 --> 30
    bar [1.78, 2.86, 6.94, 8.43, 25.4]
Loading
xychart-beta horizontal
    title "Parsing Memory"
    x-axis ["streamparser/json", jsooner, stream-json, oboe, JSON.parse]
    y-axis "Resident Set, Mb" 0 --> 750
    bar [59, 62, 85, 625, 743]
Loading

License

This project is licensed under the MIT License. See the LICENSE file for details.