我试图在下面的Cloudformation参数文件中用ParameterValue:test替换项目ParameterKey:Project
<a href="#hint" class="btn btn-info" id="hint" data-toggle="collapse"
onclick="Confirmation()">Hint</a>
function Confirmation() {
var retVal = confirm("Are you sure you want a hint");
if (retVal == true) {
<div id="hint" class="collapse">
<span style=" border: 1px solid #d6d6d6;">Answer: A </span>
</div>
**//Not sure on how to deduct 100 coins**
return true;
}
else {
document.write("User does not want to continue!");
return false;
}
}
我正在尝试执行以下jq命令
[{
"ParameterKey": "Project",
"ParameterValue": "<changeMe>"
},
{
"ParameterKey": "DockerInstanceType",
"ParameterValue": "m3.medium"
}]
我遇到以下错误
cat config.json |
jq "map(if .ParameterKey == "Project"
then . + {\"ParameterValue\":\"test\"}
else .
end)" > populated_config.json
答案 0 :(得分:1)
您要过早关闭传递给jq
的字符串,方法是不要在等号中转义“ Project”的引号。
您可以通过将表达式用单引号引起来来简化,而不必进行转义:
$ cat config.json | jq 'map(if .ParameterKey == "Project" then . + {"ParameterValue":"test"} else . end)'
[
{
"ParameterKey": "Project",
"ParameterValue": "test"
},
{
"ParameterKey": "DockerInstanceType",
"ParameterValue": "m3.medium"
}
]