I have the following json:
{
"feature/EBS_DDS_SC-27428": {
"auth": "http://test123:8080/service.jsp",
"publish": "http://test234:8080/service.jsp",
"general_name": "PG"
},
"feature/EBS_DDS_SC-27428": {
"auth": "http://ab123:8080/service.jsp",
"publish": "http://ab234:8080/service.jsp",
"general_name": "PG1"
}
}
when I do the following I get the expected result
jq --raw-output '."feature/EBS_DDS_SC-27428" | .auth'
But the following is not working,
export branch=feature/EBS_DDS_SC-27428
cat input.json | jq --raw-output '."${branch}" | .auth'
I get the following compilation error:
jq: error: syntax error, unexpected '$' (Unix shell quoting issues?) at <top-level>, line 1:
.${branch} | .auth
jq: error: try .["field"] instead of .field for unusually named fields at <top-level>, line 1:
.${branch} | .auth
jq: 2 compile errors
Now I have an environmental variable called branch
in my Linux machine