I have a JSON file with data as below:
{
"servers":{
"author-name":{
"server": "app-dv-app01"
},
"authorname2":{
"server": "app-dv-app02"
}
}
}
I am trying to access the servername based on the username here from a script with the jq as below:
jq .servers.${AUTHOR}.server
For authorname2 it is working fine and returning server app-dv-app02. But for author-name it is throwing error as below. In general I checked that if the Authorname in JSON file contains a "-" then this problem arises.
+ AUTHOR=author-name
+ cat dev-servers.json
+ jq .servers.author-name.server
jq: error: name/0 is not defined at <top-level>, line 1:
.servers.ppataky-unzer.server
jq: 1 compile error
Could someone please help here to rectify the correct syntax of jq call.
Thanks a lot.