Is it possible to change the value
of a key
in a JSON file from command line?
e.g., in package.json:
Change
{ ... ... "something": "something", "name": "idan" ... }
To
{ ... ... "something": "something", "name": "adar" ... }
One way to achieve it is by using the "json" npm package, e.g.:
json -I -f package.json -e "this.name='adar'"
Another way is by using the jq CLI, e.g.:
mv package.json temp.json jq -r '.name |= "adar"' temp.json > package.json rm temp.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With