strip-json-comments

WebJar for strip-json-comments

License

License

MIT
Categories

Categories

JSON Data
GroupId

GroupId

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

Usage

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.1.0
3.0.1
2.0.1
2.0.0
1.0.4
1.0.2