Socket
Socket
Sign inDemoInstall

strip-json-comments

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strip-json-comments - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

index.js

44

package.json
{
"name": "strip-json-comments",
"version": "1.0.4",
"version": "2.0.0",
"description": "Strip comments from JSON. Lets you use comments in your JSON files!",
"license": "MIT",
"repository": "sindresorhus/strip-json-comments",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [

@@ -20,28 +36,8 @@ "json",

"env",
"environment",
"cli",
"bin"
"environment"
],
"license": "MIT",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"files": [
"cli.js",
"strip-json-comments.js"
],
"main": "strip-json-comments",
"bin": "cli.js",
"repository": "sindresorhus/strip-json-comments",
"scripts": {
"test": "mocha --ui tdd"
},
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.8.0"
"ava": "*",
"xo": "*"
}
}

@@ -14,30 +14,19 @@ # strip-json-comments [![Build Status](https://travis-ci.org/sindresorhus/strip-json-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-json-comments)

It will remove single-line comments `//` and multi-line comments `/**/`.
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](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin.
-
*There's also [`json-comments`](https://npmjs.org/package/json-comments), but it's only for Node.js, inefficient, bloated as it also minifies, and comes with a `require` hook, which is :(*
## Install
```sh
```
$ npm install --save strip-json-comments
```
```sh
$ bower install --save strip-json-comments
```
```sh
$ component install sindresorhus/strip-json-comments
```
## Usage
```js
var json = '{/*rainbows*/"unicorn":"cake"}';
const json = '{/*rainbows*/"unicorn":"cake"}';
JSON.parse(stripJsonComments(json));

@@ -50,3 +39,3 @@ //=> {unicorn: 'cake'}

### stripJsonComments(input)
### stripJsonComments(input, [options])

@@ -59,21 +48,16 @@ #### input

#### options
## CLI
##### whitespace
```sh
$ npm install --global strip-json-comments
```
Type: `boolean`
Default: `true`
```sh
$ strip-json-comments --help
Replace comments with whitespace instead of stripping them entirely.
strip-json-comments input-file > output-file
# or
strip-json-comments < input-file > output-file
```
## Related
- [`strip-css-comments`](https://github.com/sindresorhus/strip-css-comments)
- [strip-json-comments-cli](https://github.com/sindresorhus/strip-json-comments-cli) - CLI for this module
- [strip-css-comments](https://github.com/sindresorhus/strip-css-comments) - Strip comments from CSS

@@ -80,0 +64,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc