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

jsonc-parser 3.2.1

Scanner and parser for JSON with comments.
Package summary
Share
0
issues
0
licenses
Package created
18 Apr 2016
Version published
22 Jan 2024
Maintainers
7
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does jsonc-parser do?

The jsonc-parser is a scanner and parser for JSON enriched with JavaScript style comments, or JSONC. Represented as an npm package, this tool can process standard JSON as well as JSONC in a structured and organized way. It tokenizes input strings into tokens and offsets via its scanner utility, while the visit function implements a 'SAX' style parser initiating callbacks for encountered properties and values. It evaluates JavaScript objects represented by JSON strings in a fault tolerant manner, ensuring effective processing and handling done through its parse function. The package also includes various other useful utilities such as format, modify, and applyEdits.

How do you use jsonc-parser?

To use jsonc-parser, start by installing it via npm in your project with the command npm install --save jsonc-parser. The functionality of the package can then be exploited by calling the relevant functions provided by the API. For instance, to parse JSONC text, the parse function can be used in the following way:

var jsonc = require('jsonc-parser');
var jsoncText = `{
    // this is a comment
    "key": "value"
}`;
var parsedObject = jsonc.parse(jsoncText); // parsedObject will be { key: 'value' }

Additional functionality can be utilized similarly. Errors can be checked with the parse function if required:

var jsonc = require('jsonc-parser');
var jsoncText = `{
    // this is a comment
    "key: value
}`;
var errors = [];
var parsedObject = jsonc.parse(jsoncText, errors); // errors will contain the parse error details

Where are the jsonc-parser docs?

The detailed documentation for the jsonc-parser is included within the package's README file available on its GitHub repository at https://github.com/microsoft/node-jsonc-parser. This documentation outlines all the functions, methods, and options available, such as how the scanner works, how the parser can be used, and how each utility function operates. It includes detailed code examples for each function to help users efficiently implement this npm package in their projects.