Skip to content

Instantly share code, notes, and snippets.

@pszaflarski
Created October 24, 2017 15:50
Show Gist options
  • Save pszaflarski/b6f426d8efb68f9669d902944e97d3b1 to your computer and use it in GitHub Desktop.
Save pszaflarski/b6f426d8efb68f9669d902944e97d3b1 to your computer and use it in GitHub Desktop.
convert a python dictionary to a bash/cmd compatible json for setting complicated environment variables
import json
def to_bash_json(d):
return json.dumps({'i': json.dumps(d)})[6:-1]
if __name__ == '__main__':
S3_CREDS = {
"aws_access_key_id": "AKA",
"aws_secret_access_key": "CWW"
}
j = json.dumps({'i':json.dumps(S3_CREDS)})[6:-1]
print(j)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment