【发布时间】:2019-04-10 15:23:48
【问题描述】:
我想将具有值 scan1 和 scan2 的变量 IntendedFor 添加到现有 JSON 文件中。
我想用jq函数来做这个,我试过了:
cat existing.json | jq '.IntendedFor |= "["scan1", "scan2"]"' > output.json
但我收到错误消息并且 JSON 文件为空。
这就是我希望 output.json 文件的样子:
{ "existingjsonstuff": "andsoon",
"IntendedFor": ["scan1", "scan2"]
}
我怎么得到这个??
【问题讨论】: