cat test.json | jq 'map(if ParameterKey == "Project" then . + {"ParameterValue" = "jess-project"} else . end )'
jq: error: syntax error, unexpected '=', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:
map(if ParameterKey == "Project" then . + {"ParameterValue" = "jess-project"} else . end )
jq: 1 compile error
Run Code Online (Sandbox Code Playgroud) test.sh不会替换test.json参数值($ input1和$ input2)。result.json具有相同的ParameterValue“ $ input1 / solution / $ input2.result”
[
{
"ParameterKey": "Project",
"ParameterValue": [ "$input1/solution/$input2.result" ]
}
]
Run Code Online (Sandbox Code Playgroud)
#!/bin/bash
input1="test1"
input2="test2"
echo $input1
echo $input2
cat test.json | jq 'map(if .ParameterKey == "Project" then . + {"ParameterValue" : "$input1/solution/$input2.result" } else . end )' > result.json
Run Code Online (Sandbox Code Playgroud)