Created
October 24, 2017 15:50
-
-
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
This file contains hidden or 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
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