json-streaming-parser v1.0.4
π JSON Streaming Parser
A high-performance streaming JSON parser that handles JSON like a pro! Perfect for parsing large JSON objects efficiently, with real-time partial object emission. Built with robustness in mind, it can handle malformed JSON like a champ - whether it's missing commas, wrong formatting, or even JSON written by a very enthusiastic monkey! π
β¨ Features
- π Stream processing of large JSON data
- π οΈ Fault-tolerant parsing of malformed JSON
- πββοΈ Real-time partial object updates
- πͺ Robust error handling
- π― Zero dependencies
- π¦ Lightweight (~5KB minified)
- π Type-safe with TypeScript definitions
- π¦ Event-based architecture
π§ Installation
npm install json-streaming-parser
# or
yarn add json-streaming-parser
# or
pnpm add json-streaming-parser
π Usage
Online HTML Demo
Basic Example
import { JSONStreamingParser } from 'json-streaming-parser';
try {
const parser = new JSONStreamingParser();
parser.on('updateObject', (partialObject) => {
console.log('Got partial data:', partialObject);
});
// Feed data chunks as they arrive
parser.write('{"name": "John", ');
parser.write('"age": 30, ');
parser.write('"city": "New York"}');
parser.end();
} catch (error) {
console.error('Parser error:', error);
}
π Advanced Features
Event System
updateObject
: Emitted when partial objects are parsederror
: Handling parsing errorsend
: Stream completiontimeout
: Parser timeout eventsprogress
: Parsing progress updates
π― Performance
Benchmarks run on Node.js 18.x, processing 1GB JSON file:
Parser | Memory Usage | Processing Time |
---|---|---|
JSON Streaming Parser | ~50MB | 2.3s |
JSON.parse() | ~1.2GB | 4.1s |
Other Streaming Parser | ~120MB | 3.5s |
π€ Contributing
We love contributions! Here's how you can help:
- π Report bugs
- π‘ Suggest features
- π Improve documentation
- π§ Submit PRs
Check our Contributing Guide for details.
π License
This project is licensed under the MIT License.
π’ About Hubeet
This library is proudly developed and maintained by Hubeet, an innovation hub powered by SolΓΊnika.
At SolΓΊnika, we specialize in:
π High-performance software development π Enterprise-grade security & compliance π€ AI-driven business automation π Big Data & real-time analytics π Seamless enterprise integrations
If your company needs custom software solutions with a strong focus on security, scalability, and innovation, feel free to contact us.
π Star Us!
If you find this library helpful, please give it a star! It helps others discover this solution.