tiny-jsonc is an extremely lightweight JavaScript and TypeScript library designed specifically for parsing JSONC (JSON with Comments) strings. Currently at version 1.0.2, it employs a minimal, regex-based approach to first strip comments and then trailing commas from a JSONC input string. The cleaned string is then passed directly to the native `JSON.parse` function for final object instantiation. This method prioritizes small bundle size and operational simplicity, making it particularly suitable for environments where minimizing dependencies and code footprint is critical. It does not offer advanced JSONC manipulation APIs, rich error messages, or comprehensive parsing features found in full-blown parsers. The library's stable nature and focused scope suggest a maintenance-oriented release cadence, emphasizing reliability over rapid feature development. Developers needing more robust error handling or advanced parsing capabilities are explicitly directed to alternatives like `jsonc-simple-parser`.
npm install tiny-jsoncVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and use `tiny-jsonc` to parse a JSONC string containing both single-line and multi-line comments, as well as trailing commas, into a standard JavaScript object.
Evaluate your parsing requirements. If you need robust error reporting, AST manipulation, or to handle highly unconventional JSONC structures, opt for a more feature-rich parser.
Ensure that the JSON content, *after* comments and trailing commas are removed, conforms strictly to the JSON specification (RFC 8259). Any non-standard JSON syntax will result in `JSON.parse` errors.
If encountering unexpected parsing errors with complex JSONC structures, verify the input format. For maximum robustness with highly varied or potentially malformed inputs, a more sophisticated parser that builds an Abstract Syntax Tree (AST) might be necessary.
Inspect the JSONC input around the indicated position (X) for unusual comment formatting or edge cases that the regex might miss. Ensure comments follow standard JSONC syntax (`//` for line, `/* */` for block comments).
Verify the JSONC input around the indicated position for correctly placed commas. `tiny-jsonc` specifically targets *trailing* commas; other misplaced commas will still cause errors from `JSON.parse`.
No dependency data recorded yet.