JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 91875158
  • Score
    100M100P100Q257639F
  • 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"
}

There's already json-comments, but it's only for Node.js and uses a naive regex to strip comments which fails on simple cases like {"a":"//"}. This module however parses out the comments.

Install

Download manually or with a package-manager.

npm

npm install --save strip-json-comments

Or globally if you want to use it as a CLI app:

npm install --global strip-json-comments

You can then use it in your Terminal like:

strip-json-comments with-comments.json > without.json

Or pipe something to it:

cat with-comments.json | strip-json-comments > without.json

Bower

bower install --save strip-json-comments

Component

component install sindresorhus/strip-json-comments

Examples

Node.js

var stripJsonComments = require('strip-json-comments');
var json = '{//rainbows\n"unicorn":"cake"}';
JSON.parse(stripJsonComments(json));
//=> {unicorn: 'cake'}

Bower

<script src="bower_components/strip-json-comments/strip-json-comments.js"></script>
var json = '{//rainbows\n"unicorn":"cake"}';
JSON.parse(stripJsonComments(json));
//=> {unicorn: 'cake'}

API

stripJsonComments(string)

Accepts a string with JSON and strips out the comments.

License

MIT © Sindre Sorhus