Answer for original question
Let's start with your variable:
$ echo "$var"
{'active-production-dc':'sc-tx2','standby-production-dc':'sc-tx3','active-integration-dc':'int-tx3','standby-integration-dc':'int-va1'}
Using jq
jq does not accept the string as is. We must first replace the single-quotes with double-quotes. Then we can extract the keys:
$ echo "$var" | sed 's/'\''/"/g' | jq keys
[
"active-integration-dc",
"active-production-dc",
"standby-integration-dc",
"standby-production-dc"
]
Using awk
Using awk to extract the keys:
$ printf "%s" "$var" | awk 'NR%2==0' RS="({'|'.'|'})"
active-production-dc
standby-production-dc
active-integration-dc
standby-integration-dc
Using awk to extract the values that correspond to those keys:
$ printf "%s" "$var" | awk 'NR>1 && NR%2' RS="({'|'.'|'})"
sc-tx2
sc-tx3
int-tx3
int-va1
Answer for revised question
For the revised question, we need a new var:
$ echo "$var"
{'active_production_dc':'sc-tx2','standby_production_dc':'sc_tx3','active_integration_dc':'int_tx3','standby_integration_dc':'int_va1'}
We can create shell variables named after the keys like this:
$ while IFS=":" read -r -d, key val; do declare "$key=$val"; done < <(echo "$var" | sed "s/[{}']//g; s/$/,/")
When this is done the keys and values are accessible:
$ echo "$active_production_dc"
sc-tx2
Alternatively, and probably preferably, we can make the keys and values available in bash via an associative array. Use:
declare -A a
while IFS=":" read -r -d, key val
do
a["$key"]="$val"
done < <(echo "$var" | sed "s/[{}']//g; s/$/,/")
When this is run, using the value for var in the revised question, then the resulting a contains the keys and values:
$ declare -p a
declare -A a='([standby_integration_dc]="int_va1" [active_production_dc]="sc-tx2" [active_integration_dc]="int_tx3" [standby_production_dc]="sc_tx3" )'
An individual value can be accessed via its key:
$ echo "${a[active_production_dc]}"
sc-tx2