dot-json
---
Easily edit a json file from the CLI or NodeJS.
Install global
npm install -g dot-jsonor local
npm install dot-jsonUse from the CLI
dot-json myfile.json user.name "John Doe"
dot-json myfile.json user.email "john@example.com"
dot-json myfile.json foo..bar baz
dot-json myfile.json address '{"city":"Atlantis"}' --json-valuemyfile.json now looks like
{
"user": {
"name": "John Doe",
"email": "john@example.com"
},
"foo.bar": "baz",
"address": {
"city": "Atlantis"
}
}dot-json myfile.json user.name
John DoeUsage:
dot-json <file> <key-path> Get a value from a json file by key-path
dot-json <file> <key-path> <value> Assign a value at a key-path
dot-json <file> <key-path> --delete Delete a key by key-path
Options:
--indent=<n> Indent with <n> of white space characters [default: auto]
-d --delete Delete the key-path
-j --json-value Parse the input value as a JSON string (to set whole objects or arrays)
-h --help Show this message with options
-v --version Print the version numberQuick tip for editing package.json
If you want to change package.json, you can use npm’s pkg command instead of dot-json:
npm pkg get scripts.test
npm pkg set name=my-new-packageUse it in NodeJS
#### Initialization