I'm trying to pass a json data to jq
command and replace a value like sed
. But it's just printing the command and not executing it.
jsonStr, _ := json.Marshal(p.Values)
op, _ := exec.Command("echo", string(jsonStr), "| jq '.aws=1'").CombinedOutput()
fmt.Println(string(op))
It's just printing the value of p.Values
which is a json and | jq '.aws=1'
instead of replacing the aws
key in p.Values
and printing it.
The output is something like this.
{"name": "n1"} | jq '.aws=1'
But if I execute the same command from terminal, it's working fine and replacing the text in json.