jq: error: test1/0 is not defined at <top-level>, line 1
Using shell-based variable interpolation is usually a very bad idea. In the present case, what if the shell variable contains a double-quotation mark, for example?
The safe thing to do is to use env
or --arg
or --argjson
as appropriate, e.g.
jq --arg e "${Environment_Name}" '.environments[$e] += ["test1"]'
You have some extra quotes in there and test1
needs to be ["test1"]
jq ".environments.${Environment_Name} += [\"test1\"]" tmp.json