mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 13:13:37 +08:00
Change-Id: I3fcf49bc416301a030d298cfc48c448bfeba4335 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1878808 Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Paul Lewis <aerotwist@chromium.org>
strip-json-comments 
Strip comments from JSON. Lets you use comments in your JSON files!
This is now possible:
{
// rainbows
"unicorn": /* ❤ */ "cake"
}
It will replace single-line comments // and multi-line comments /**/ with whitespace. This allows JSON error positions to remain as close as possible to the original source.
Also available as a gulp/grunt/broccoli plugin.
Install
$ npm install --save strip-json-comments
Usage
const json = '{/*rainbows*/"unicorn":"cake"}';
JSON.parse(stripJsonComments(json));
//=> {unicorn: 'cake'}
API
stripJsonComments(input, [options])
input
Type: string
Accepts a string with JSON and returns a string without comments.
options
whitespace
Type: boolean
Default: true
Replace comments with whitespace instead of stripping them entirely.
Related
- strip-json-comments-cli - CLI for this module
- strip-css-comments - Strip comments from CSS
License
MIT © Sindre Sorhus