jsonc-simple-parser is a lightweight and performant JavaScript/TypeScript library designed to parse JSON-like data that includes comments (JSONC) and optional trailing commas. Currently stable at version 3.0.0, this package stands out for its minimal bundle size, being approximately 3.5kb minified and gzipped (or ~2kb if `RegHex` is already in your bundle). It boasts exceptional performance, often being 10x faster than VS Code's `jsonc-parser` and 70x faster than `JSON5` for standard JSON, and equally fast for JSONC. The library prioritizes correctness by passing all 274 JSON tests from ECMA's test262 suite, ensuring reliable parsing despite its non-spec-compliant nature (as standard JSON does not allow comments or trailing commas). It ships with built-in TypeScript types for an enhanced developer experience.
npm install jsonc-simple-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a JSONC string containing comments and trailing commas, and then stringifying a plain object back to standard JSON.
Review the official changelog or release notes for `jsonc-simple-parser` v3.0.0 on its GitHub repository to understand any API changes or behavioral modifications and update your code accordingly.
If you need to preserve comments or trailing commas, `jsonc-simple-parser` does not provide this functionality on stringification. Consider alternative approaches or other libraries if comment preservation is a requirement for output.
Be aware that output generated by `JSONC.stringify` (which is standard JSON) will lose these non-standard features. Ensure downstream systems expecting strict JSON will not encounter issues if you manually re-introduce comments for human readability.
Replace `JSON.parse(jsoncString)` with `JSONC.parse(jsoncString)`.
Ensure you are using `import JSONC from 'jsonc-simple-parser';` for ESM, or if in CommonJS, try `const JSONC = require('jsonc-simple-parser').default;` (though ESM `import` is recommended).Run `npm install jsonc-simple-parser` or `yarn add jsonc-simple-parser`. Ensure your `tsconfig.json` has `moduleResolution` set appropriately (e.g., `bundler` or `node16`) and that the module is correctly referenced in your import statements.
No dependency data recorded yet.