I have file.json
in the structure of:
{
"connections": {}
}
I want to update the connections object with variables $1
and $2
. I'm trying:
jq --arg ssid "$1" --arg pass "$2" '.connections.$ssid = "$pass"' file.json > tmp.json && mv tmp.json file.json
But I'm getting back jq: error: syntax error, unexpected '$', expecting FORMAT or QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:
.connections.$ssid = "$pass"
I'm expecting script.sh value key
to produce:
{
"connections": {key:"value"}
}
How can I update the object with multiple arguments