Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 11, 2024 via pnpm

strip-json-comments 3.1.1

Strip comments from JSON. Lets you use comments in your JSON files!
Package summary
Share
0
issues
1
license
1
MIT
Package created
17 Nov 2013
Version published
12 Jul 2020
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
strip-json-comments@3.1.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of strip-json-comments 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does strip-json-comments do?

The npm package "strip-json-comments" is designed to remove comments from JSON files. This includes both single-line comments (marked with //) and multi-line comments (marked with /**/). By replacing these comments with whitespace, it preserves JSON error positions, aligning them as closely as possible to the original code. Furthermore, this package allows you to incorporate comments in your JSON files for improved readability without affecting their functionality.

How do you use strip-json-comments?

The "strip-json-comments" package is straightforward to use:

First, install it using your Node.js package manager, like so:

npm install strip-json-comments

Then, you can use it in your JavaScript code to strip comments from a JSON string.

Here's an example:

import stripJsonComments from 'strip-json-comments';

const json = `{
    // A rainbow comment
    "unicorn": /* Heart emoji comment */ "cake"
}`;

JSON.parse(stripJsonComments(json));
// This yields: {unicorn: 'cake'}

In this example, the JSON string includes two comments. With the stripJsonComments() function, these are removed, and you can parse the result into a valid JSON object. The function also comes with options to handle trailing commas and replace comments with whitespace.

Where are the strip-json-comments docs?

The documentation for the "strip-json-comments" package can be found in its README file on the GitHub repository, available at https://github.com/sindresorhus/strip-json-comments. This includes detailed usage instructions, API descriptions, and links to related packages.