1.0.4 β€’ Published 4 months ago

json-streaming-parser v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

πŸš€ JSON Streaming Parser

npm version Downloads License PRs Welcome

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

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 parsed
  • error: Handling parsing errors
  • end: Stream completion
  • timeout: Parser timeout events
  • progress: Parsing progress updates

🎯 Performance

Benchmarks run on Node.js 18.x, processing 1GB JSON file:

ParserMemory UsageProcessing Time
JSON Streaming Parser~50MB2.3s
JSON.parse()~1.2GB4.1s
Other Streaming Parser~120MB3.5s

🀝 Contributing

We love contributions! Here's how you can help:

  1. πŸ› Report bugs
  2. πŸ’‘ Suggest features
  3. πŸ“ Improve documentation
  4. πŸ”§ 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.