I think that your command does not "require" single quotes around that JSON
string. It's a shell that requires them to treat the entire JSON
string as a single word and pass it to $COMMAND
.
There are 2 ways to use it in JSON string (I set var
to 999):
$ echo command "[{\"name\": \"john\", \"tel\": ${var}}]"
command [{"name": "john", "tel": 999}]
or:
$ echo command '[{"name": "john", "tel": '"${var}"'}]'
command [{"name": "john", "tel": 999}]
However, if your command really requires JSON string enclosed in single quotes do this:
"'[{\"name\": \"john\", \"tel\": ${var}}]'"
Also, [
and ]
might not be needed:
"{\"name\": \"john\", \"tel\": ${var}}"