Created
May 16, 2016 12:56
-
-
Save pgilad/e8ffd8ce2bde81a1a375e86df77a34ab to your computer and use it in GitHub Desktop.
Convert a json file to toml
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
#!/usr/bin/env python2 | |
# don't forget to `pip install toml` | |
import json | |
import sys | |
import toml | |
if len(sys.argv) < 3: raise Exception('Usage is `json_to_toml.py input.json output.toml`') | |
json_file = sys.argv[1] | |
output_file = sys.argv[2] | |
with open(json_file) as source: | |
config = json.loads(source.read()) | |
toml_config = toml.dumps(config) | |
with open(output_file, 'w') as target: | |
target.write(toml_config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment