strip-json-comments
Strip comments from JSON. Lets you use comments in your JSON files!
by sindresorhusJavaScript
Commit activity
Last 12 weeks · 1 commit
Community health
4 of 6 standards met
Recent fixes
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.
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.