Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@luojianet/remove-json-comments

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luojianet/remove-json-comments

remove json comments

  • 1.0.2
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

remove-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 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 remove-json-comments

Usage

const json = '{/*rainbows*/"unicorn":"cake"}';

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

JSON Remove trailiing comma from last object

var json = `
{
    [  
        {  
            "ITEM2":{  
                "names":[  
                    "nameB",
                    "nameC"
                ]
            }
        }, // need to remove this comma!
    ]
}`
JSON.parse(stripJsonComments(json));

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.

Benchmark

$ npm run bench

License

MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 21 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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