且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过命令行在JSON文件中修改密钥的值

更新时间:2023-12-03 22:40:22

一种实现方法是使用"json" npm程序包,例如:

One way to achieve it is by using the "json" npm package, e.g.:

json -I -f package.json -e "this.name='adar'"

另一种方法是使用 jq CLI ,例如:

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