Last active
January 26, 2019 08:49
-
-
Save andmos/4a184d04d80fb2b499cd80d925e86eea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jsonToEnvironment { | |
if [ -f $1 ]; then | |
for s in $(jq -r "to_entries|map(\"\(.key)=\(.value|tostring)\")|.[]" $1) | |
do | |
export $s | |
done | |
fi | |
} | |
### Usage: | |
### $ cat someJson.json | |
### { | |
### "myProperty" : "value" | |
### } | |
### $ jsonToEnvironment someJson.json | |
### $ echo $myProperty | |
### value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment