strip-json-comments

WebJar for strip-json-comments

License

License

MIT
Categories

Categories

JSON Data
GroupId

GroupId

org.webjars.bowergithub.sindresorhus
ArtifactId

ArtifactId

strip-json-comments
Last Version

Last Version

3.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

strip-json-comments
WebJar for strip-json-comments
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/strip-json-comments

Download strip-json-comments

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.sindresorhus/strip-json-comments/ -->
<dependency>
    <groupId>org.webjars.bowergithub.sindresorhus</groupId>
    <artifactId>strip-json-comments</artifactId>
    <version>3.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.sindresorhus/strip-json-comments/
implementation 'org.webjars.bowergithub.sindresorhus:strip-json-comments:3.1.1'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.sindresorhus/strip-json-comments/
implementation ("org.webjars.bowergithub.sindresorhus:strip-json-comments:3.1.1")
'org.webjars.bowergithub.sindresorhus:strip-json-comments:jar:3.1.1'
<dependency org="org.webjars.bowergithub.sindresorhus" name="strip-json-comments" rev="3.1.1">
  <artifact name="strip-json-comments" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.sindresorhus', module='strip-json-comments', version='3.1.1')
)
libraryDependencies += "org.webjars.bowergithub.sindresorhus" % "strip-json-comments" % "3.1.1"
[org.webjars.bowergithub.sindresorhus/strip-json-comments "3.1.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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

Usage

const stripJsonComments = require('strip-json-comments');

const json = `{
	// Rainbows
	"unicorn": /* ❤ */ "cake"
}`;

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

API

stripJsonComments(jsonString, options?)

jsonString

Type: string

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

options

Type: object

whitespace

Type: boolean
Default: true

Replace comments with whitespace instead of stripping them entirely.

Benchmark

$ npm run bench

Related


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Version
3.1.1
3.0.1
2.0.1