Skip to content

Instantly share code, notes, and snippets.

@andmos
Last active January 26, 2019 08:49
Show Gist options
  • Save andmos/4a184d04d80fb2b499cd80d925e86eea to your computer and use it in GitHub Desktop.
Save andmos/4a184d04d80fb2b499cd80d925e86eea to your computer and use it in GitHub Desktop.
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