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:
- Parse partial JSON string
- Supports Node and all browsers
- Instantly parse JSON string that generated by AI
npm install --save json-fragment-parser
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"]
https://codesandbox.io/s/json-fragment-parser-demo-3pnksv?file=/src/App.js