JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 89401373
  • Score
    100M100P100Q266870F
  • License MIT

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

Package Exports

  • strip-json-comments
  • strip-json-comments/strip-json-comments

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (strip-json-comments) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

strip-json-comments Build Status

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

This is now possible:

{
    // rainbows
    "unicorn": /* ❤ */ "cake"
}

It will remove single-line comments // and multi-line comments /**/.

Also available as a gulp/grunt/broccoli plugin.

There's also json-comments, but it's only for Node.js, inefficient, bloated as it also minifies, and comes with a require hook, which is :(

Install

$ npm install --save strip-json-comments
$ bower install --save strip-json-comments
$ component install sindresorhus/strip-json-comments

Usage

var json = '{/*rainbows*/"unicorn":"cake"}';
JSON.parse(stripJsonComments(json));
//=> {unicorn: 'cake'}

API

stripJsonComments(input)

input

Type: string

Accepts a string with JSON and returns a string without comments.

CLI

$ npm install --global strip-json-comments
$ strip-json-comments --help

strip-json-comments input-file > output-file
# or
strip-json-comments < input-file > output-file

License

MIT © Sindre Sorhus