Use env variable in jq as json key
Jq allows you to pass ENV variable as arg
and use it to extract certain key from json. Example:
json='{"data":{"test":{"some_key":"some_value"},"test2":{"some_key":"other_value"}}}'
KEY="test2"
jq --arg key "$KEY" '.data[$key].some_key' <<<"$json"
Tweet