【发布时间】:2017-11-20 01:50:12
【问题描述】:
在 shell 脚本中使用两个 jq 映射时,我发现以下数据出现错误。
test.json
[
{
"ParameterKey": "<ans1>",
"ParameterValue": "<ans2>"
}
]
我的脚本是
cat test.json | \
jq 'map(if .ParameterKey == "<ans1>" then . + {"ParameterKey" : "input1" } else . end )' \
'map(if .ParameterValue == "<ans2>" then . + {"ParameterValue" : "input2" } else . end)' \
> result.json
【问题讨论】: