JSPM

parse-part-json

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q19285F
  • License ISC

Can parse an incomplete JSON string

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.0

这是一个可以解析不完整 json 的库

Installation

$ npm i parse-part-json

Demo

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