Socket
Book a DemoInstallSign in
Socket

jsonsurge

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonsurge

A JSON parsing utility for streaming data

latest
npmnpm
Version
1.0.6
Version published
Weekly downloads
21
110%
Maintainers
1
Weekly downloads
 
Created
Source

StreamJSONParser

StreamJSONParser is a JavaScript module that provides a way to parse JSON data from a readable stream in an asynchronous and efficient manner. It is particularly useful when dealing with streaming JSON data, such as data received from server-sent events (SSE) or other real-time data sources.

Installation

You can install StreamJSONParser using npm or yarn:

npm install stream-json-parser

or

yarn add stream-json-parser

Usage

To use StreamJSONParser, you need to import it into your JavaScript or TypeScript code:

import streamJSONParser from 'stream-json-parser';

Example Usage

Here is an example of how to use StreamJSONParser to parse JSON data from a readable stream:

import streamJSONParser from 'stream-json-parser';

// Create a ReadableStream (e.g., from a fetch response)
const response = await fetch('https://example.com/streaming-data');
const stream = response.body;

for await (const chunk of streamjsonparser(response.body)) {
                console.log(chunk)
            }

How It Works

The streamJSONParser function accepts a readable stream as its input and returns an asynchronous generator that yields parsed JSON objects as they are received from the stream.

Contributing

If you'd like to contribute to StreamJSONParser, please open an issue or submit a pull request on GitHub.

License

StreamJSONParser is licensed under the MIT License.

Acknowledgments

StreamJSONParser is inspired by the need for efficient parsing of streaming JSON data in real-time applications.

About

StreamJSONParser is maintained by Gaurav mishra. You can contact me at garvmishra9@gmail.com.

For more information, visit the GitHub repository.

FAQs

Package last updated on 25 Sep 2023

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