tolerant-json-parser

Tolerant JSON parser

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
tolerant-json-parser
001.0.1a year agoa year agoMinified + gzip package size for tolerant-json-parser in KB

Readme

Tolerant JSON parser
!npm packagenpm-imgnpm-url npm bundle size !Build Statusbuild-imgbuild-url !Downloadsdownloads-imgdownloads-url !Issuesissues-imgissues-url !Commitizen Friendlycommitizen-imgcommitizen-url !Semantic Releasesemantic-release-imgsemantic-release-url
A very tolerant JSON parser. It supports all the current JSON standard, along with the following tollerances added:
  • Unquoted keys
  • Single-quotes strings
  • Multi-line template strings without interpolations (some string)
  • Multi-line comments (/\* ... \*/)
  • Single-line comments (// ...)
  • Trailing commas

Warning This package does not work with Safari browser as Safari still does not support lookbehind in JS regular expression

Install

npm install tolerant-json-parser

Usage

import { parse } from 'tolerant-json-parser';

parse(`
{
  
  [\`some template string without interpolation\`]: \`
    some multline template string
    without interpolation
  \`,/*
    some multiline comment
  */
  foo: 'bar',
  "baz": false, // some single-line comment
  'foo-baz': [1,2,3, ],
`);