Skip to content

SimonTart/json-fragment-parser

Repository files navigation

JSON Fragment Parser

Primarily used in scenarios such as generating JSON with AI models like ChatGPT, it can parse the content of an incomplete JSON generated by AI, and then be used to render data early on, enhancing user experience.

Feat:

  1. Parse partial JSON string
  2. Supports Node and all browsers
  3. Instantly parse JSON string that generated by AI

中文文档

CI

Install

npm install --save json-fragment-parser

Usage

import { jsonParse } from 'json-fragment-parser';
const objData = jsonParse('{ title: "hello world", content: "hello ');
// { title: "hello world", content: "hello" }

const arrData = jsonParse('["apple", "ora');
// ["apple", "ora"]

Demo

https://codesandbox.io/s/json-fragment-parser-demo-3pnksv?file=/src/App.js

About

parse partial json string

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published