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



bash
npm install -g jsonc-cli
`Usage
`txt
jsonc [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
$3
`bash
echo '{"animal":"dog"}' | jsonc read '["animal"]' -r
`
will print dogTo print without newline add
-n$3
`bash
echo '{"animal":"dog" // with some comments\n}' | jsonc format
`
will print
`jsonc
{
"animal": "dog" // with some comments
}
`
$3
`bash
echo '{"animal":"dog"}' | jsonc modify -p '["animal"]' -v '"cat"'
`
will print
`json
{"animal":"cat"}
`$3
`bash
echo '{"animal":"dog"}' | jsonc read '["animal"]' -r -f output.txt
cat output.txt # dog
`
$3
It is important to add the -n when you modify to prevent additional trailing new lines to be added
`bash
cat .vscode/settings.json | jsonc modify -n -p '["typescript.tsdk"]' -v '"app/node_modules/typescript/lib"' -f .vscode/settings.json
``