🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

jsonc-cli

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonc-cli

Read and modify JSONC documents. A CLI front-end for the jsonc-parser npm package

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
161
-41.88%
Maintainers
1
Weekly downloads
 
Created
Source

jsonc-cli

Read and modify JSONC documents (JSON with comments). A CLI front-end for the jsonc-parser npm package.

npm npm GitHub Repo stars

Installation

npm install -g jsonc-cli

Usage

jsonc <cmd> [args]

Commands:
  jsonc modify           Modify a JSONC document from stdin. Formatting options
                         are only applied to the injected JSON
  jsonc format           Format a JSONC document from stdin
  jsonc read [JSONPath]  Prints the JSON value at the given path in a JSONC
                         document from stdin

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]

Examples

Print a value

echo '{"animal":"dog"}' | jsonc read '["animal"]' -r

will print dog

To print without newline add -n

Format document

echo '{"animal":"dog" // with some comments\n}' | jsonc format

will print

{
  "animal": "dog" // with some comments
}

Modify document

echo '{"animal":"dog"}' | jsonc modify -p '["animal"]' -v '"cat"'

will print

{"animal":"cat"}

Write to file

echo '{"animal":"dog"}' | jsonc read '["animal"]' -r -f output.txt
cat output.txt # dog

Modify a file

It is important to add the -n when you modify to prevent additional trailing new lines to be added

cat .vscode/settings.json | jsonc modify -n -p '["typescript.tsdk"]' -v '"app/node_modules/typescript/lib"' -f .vscode/settings.json

Keywords

jsonc

FAQs

Package last updated on 28 Nov 2022

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