sindresorhus

strip-json-comments

Strip comments from JSON. Lets you use comments in your JSON files!

by sindresorhus

JavaScript

JavaScript95.6%
TypeScript4.4%

Commit activity

Last 12 weeks · 1 commit

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template
cspotcode

supports comments but also trailing commas. For example: It would be nice to have a flag that enables stripping of these trailing commas. I bet we can do this by tracking the location of the most recently encountered comma, and detecting when we hit a or . Both of those characters signal that the comma was trailing and can be either removed or replaced with a space. This may add a tiny bit of complexity to the statements. Instead of , we might want to do and then flush the accumulator to the result as soon as we have determined that the most recently-encountered comma is or is not trailing. That way, will start where the comma is, and we'll have a good way to strip that comma if necessary. I can probably attempt an implementation in the near-term. My use-case requires CJS support, so I may do this in a fork, but I can at the very least share the patch here.

cspotcode · 2w ago
brleinad

Fix #51 Ignore Invalid Comments Updated parsing logic to account for when a comment doesn't get closed. Updated failing test -> now all tests pass 🎉

brleinad · 1y ago
sindresorhus

For example, should be ignored. https://github.com/sindresorhus/strip-json-comments/blob/ad70a18c06f5a3c93f02f855489d1c0f900f43d3/test.js#L67-L70

sindresorhus · 1y ago
Structured data for AI agents

Repository: sindresorhus/strip-json-comments. Description: Strip comments from JSON. Lets you use comments in your JSON files! Stars: 625, Forks: 55. Primary language: JavaScript. Languages: JavaScript (95.6%), TypeScript (4.4%). License: MIT. Topics: json, json-comments, jsonc, npm-package. Latest release: v5.0.3 (1y ago). Open PRs: 0, open issues: 0. Last activity: 1mo ago. Community health: 85%. Top contributors: sindresorhus, lydell, blakeembrey, BendingBender, EdwardBetts, joshuajaco, kevva, papb, C0ldF0x, Richienb and others.