If I have a JSON like this,
{"hello1": "world1","testk": "testv"}
And I want to export each of these key-value pairs as environment variables, how to do it via shell script? So for example, when I write on the terminal, echo $hello1
, world1
should be printed and similarly for other key-value pairs?Note: The above JSON is present in a variable called $values
and not in a file.
I know it will be done via jq
and written a shell script for this, but it doesn't work.
for row in $(echo "${values}" | jq -r '.[]'); do -jq() { echo ${row} | jq -r ${1} } echo $(_jq '.samplekey')done