Package Exports
- parse-part-json
- parse-part-json/dist/cjs/index.cjs
- parse-part-json/dist/esm/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-part-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
parse-part-json v1.0.1
This is a library that can parse incomplete JSON
Installation
$ npm i parse-part-jsonDemo
import { parsePartJson } from 'parse-part-json'Commonjs:
const { parsePartJson } = require('parse-part-json')Example:
/**
* note: This is not a complete JSON
*/
const json1 = `{"name": "John", "age": 30`
const result1 = parsePartJson(json1)
console.log(result1) // { name: 'John', age: 30 }
/**
* Default tolerance for incomplete parsing of basic types
*/
const json2 = `{"name": "John", "age":nu`
const result2 = parsePartJson(json2)
console.log(result2) // { name: 'John', age: null }
// this throw BasicParseIncomplete Error
const result3 = parsePartJson(json2, { tolerateBasicIncomplete: false })Support
ESModule、Commonjs