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

jsonc-parser

Package Overview
Dependencies
Maintainers
0
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonc-parser

Scanner and parser for JSON with comments.

  • 3.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20M
decreased by-0.18%
Maintainers
0
Weekly downloads
 
Created

What is jsonc-parser?

The jsonc-parser npm package is used for parsing and manipulating JSONC (JSON with Comments) files. It provides functionality to parse JSONC content, extract errors, and visit nodes within the JSONC structure. It also allows for modifications and formatting of the JSONC content.

What are jsonc-parser's main functionalities?

Parsing JSONC

This feature allows you to parse JSONC content, which includes comments, without stripping them out. It can handle both single-line and multi-line comments.

{"text": "// This is a comment\n{\"key\": \"value\"}"}

Extracting Errors

jsonc-parser can extract errors from JSONC content, which is useful for validating and providing feedback on the correctness of the JSONC.

{"text": "{\"key\": \"value\", // invalid comment\n}"}

Visiting Nodes

This feature allows you to visit nodes within the JSONC structure and perform operations or analysis on them, such as logging property names.

{"text": "{\"key\": {\"nestedKey\": \"nestedValue\"}}", "visitor": {"onObjectProperty": (property, visitContext) => { console.log(property); }}}

Modifying JSONC

jsonc-parser provides functionality to modify the JSONC content by specifying the path to the node and the new value.

{"text": "{\"key\": \"value\"}", "modifications": [{"path": [\"key\"], "value": \"newValue\"}]}

Formatting JSONC

This feature allows you to format JSONC content according to specified formatting options, such as using spaces or tabs for indentation.

{"text": "{\"key\":\"value\"}", "options": {"insertSpaces": true, "tabSize": 2}}

Other packages similar to jsonc-parser

FAQs

Package last updated on 24 Jun 2024

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