I have to replace a value in a json file with the value of a bash variable. This is the sample json.
{ "swagger": "2.0", "info": {
"title": "DataSyncGtest",
"version": "2.0",
"description": "Lorem,ipsum,dorem" }, "host": "stg.api.realogyfg.com", "basePath": "/v2/xxx/yyy/Newproxytest"
}
I used the below command and was able to replace the value of the basePath(Thanks to @Cyrus for pointing me with the right answers that helped). Command:
foo=/v1/proxytest
cat $NAME | jq --arg foo "$foo" '.basePath = $foo' > test.json
But am doing this from a bash task in Azure DevOps and it adds the below instead of just the value of the variable. I'm not sure how this can be avoided.
{
"swagger": "2.0",
"info": {
"title": "DataSyncGtest",
"version": "2.0",
"description": "blah"
},
"host": "stg.api.realogyfg.com",
"basePath": "C:/Program Files/Git/v1/proxytest",
}