Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jackardios/tolerant-json-parser
A very tolerant JSON parser.
https://github.com/jackardios/tolerant-json-parser
json json-parser parser tolerant tolerant-parser
Last synced: 26 days ago
JSON representation
A very tolerant JSON parser.
- Host: GitHub
- URL: https://github.com/jackardios/tolerant-json-parser
- Owner: Jackardios
- License: mit
- Created: 2023-01-17T21:05:27.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-20T07:24:30.000Z (over 1 year ago)
- Last Synced: 2024-04-24T19:11:56.611Z (7 months ago)
- Topics: json, json-parser, parser, tolerant, tolerant-parser
- Language: TypeScript
- Homepage:
- Size: 194 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tolerant JSON parser
[![npm package][npm-img]][npm-url]
![npm bundle size](https://img.shields.io/bundlephobia/minzip/tolerant-json-parser)
[![Build Status][build-img]][build-url]
[![Downloads][downloads-img]][downloads-url]
[![Issues][issues-img]][issues-url]
[![Commitizen Friendly][commitizen-img]][commitizen-url]
[![Semantic Release][semantic-release-img]][semantic-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](https://caniuse.com/js-regexp-lookbehind)## Install
```bash
npm install tolerant-json-parser
```## Usage
```ts
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, ],
`);
```[build-img]: https://github.com/jackardios/tolerant-json-parser/actions/workflows/release.yml/badge.svg
[build-url]: https://github.com/jackardios/tolerant-json-parser/actions/workflows/release.yml
[downloads-img]: https://img.shields.io/npm/dt/tolerant-json-parser
[downloads-url]: https://www.npmtrends.com/tolerant-json-parser
[npm-img]: https://img.shields.io/npm/v/tolerant-json-parser
[npm-url]: https://www.npmjs.com/package/tolerant-json-parser
[issues-img]: https://img.shields.io/github/issues/jackardios/tolerant-json-parser
[issues-url]: https://github.com/jackardios/tolerant-json-parser/issues
[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-release-url]: https://github.com/semantic-release/semantic-release
[commitizen-img]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
[commitizen-url]: http://commitizen.github.io/cz-cli/