我有以下 JSON 文件位于/tmp/target.json
:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
...
}
}
我想添加一个新的键值对,如下所示:
{
"compileOnSave": false,
"compilerOptions": {
"skipLibCheck": true,
"baseUrl": "./",
...
}
}
我使用以下命令但它不起作用:
jq --argjson addobj '{"skipLibCheck": "true"}' '
.compilerOptions{} |= $addobj
' /tmp/target.json
我给了我这个错误:
jq: error: syntax error, unexpected '{', expecting $end (Unix shell quoting issues?) at <top-level>, line 2:
.compilerOptions{} |= $addobj
jq: 1 compile error
我做错了什么?我怎样才能让它按预期工作?