json-fragment-parser
v0.5.1
Published
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.
Downloads
4
Readme
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.
Supports Node and all browsers.
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