Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 609

Exporting JSON to environment variables

$
0
0

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

Viewing all articles
Browse latest Browse all 609

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>