npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

streaming-json

v0.1.4

Published

A streamlined, user-friendly JSON streaming preprocessor, crafted in JavaScript.

Downloads

14

Readme

streaming-json

codecov license npm NPM downloads

Welcome to streaming-json-js, a groundbreaking library designed to revolutionize the way we handle stream JSON parsing.

In an era dominated by LLMs (Large Language Models), the ability to efficiently parse JSON streams is more critical than ever. Traditionally, JSON parsing libraries have fallen short, requiring JSON data to be fully generated before any parsing can begin. streaming-json-go challenges this limitation head-on.

Key Features

  • Real-Time JSON Parsing: With streaming-json-go, you no longer need to wait for the entire JSON data to be generated. This library allows for the parsing of JSON as it is being streamed (this means JSON stream can stops at any position), significantly cutting down the time-to-first-token.
  • Seamless Integration: Designed to complement existing JSON parsing libraries, streaming-json-go preprocesses incomplete JSON strings, transforming them into valid, parseable JSON. This means you can continue using your preferred JSON library with our tool seamlessly.
  • Enhanced User Experience: By enabling real-time data processing, our library drastically reduces the wait time for end-users. Display JSON structures to users without the delay typically associated with complete JSON generation.

Usage Instructions

Using npm, download and install the code.

$ npm install --save streaming-json

For node environment:

const streamingjson = require('streaming-json');

For webpack or similar environment:

import streamingjson from 'streaming-json';

For browser environment:

<script src="node_modules/streaming-json/dist/index.aio.js"></script>

Example Usage

Basically, this library is used to complete fragmented JSON, making it into syntactically correct JSON. For example:

{"a": will complete to {"a":null}

and When the JSON stream continues to output as:

{"a":[tr will complete to {"a":[true]}

Do not worry about the JSON stream stopping anywhere, such as at a comma:

{"a":[true], will complete to {"a":[true]}

Escaped characters? No problem:

{"a":[true], "b": "this is unicode \u54" will complete to {"a":[true], "b": "this is unicode "}

(After the stream outputs the complete Unicode, it will then display.)

Here’s a quick example to get you started:

// init, @NOTE: We need to assign a new lexer for each JSON stream.
lexer = new streamingjson.Lexer();

// append your JSON segment
lexer.AppendString(`{"a":`)

// complete the JSON
console.log(lexer.CompleteJSON()); // will print `{"a":null}`

// append more JSON segment
lexer.AppendString(`[tr`)

// complete the JSON again
console.log(lexer.CompleteJSON()); // will print `{"a":[true]}`

For more examples please see: examples

Characteristics

  • Coded in ES6+ or TypeScript, easily compile and generate production code
  • Supports multi environment, including default browsers, Node, AMD, CMD, Webpack, Rollup, Fis and so on.
  • Integrated jsmini

Note: When export and export default are not used at the same time, there is the option to turn on legacy mode. Under legacy mode, the module system can be compatible with IE6-8. For more information on legacy mode, please see rollup supplemental file.

Compatibility

Unit tests guarantee support on the following environment:

| IE | CH | FF | SF | OP | IOS | Android | Node | | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ----- | | 11+ | 100+ | 100+ | 16+ | 100+ | 10.3+ | 4.1+ | 16+ |

Note: Compiling code depend on ES5, so you need import es5-shim to compatible with IE6-8, here is a demo

Try to Find This Library in Another Programming Language?

Please see:

License

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