Skip to content

Instantly share code, notes, and snippets.

@pgilad
Created May 16, 2016 12:56
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pgilad/e8ffd8ce2bde81a1a375e86df77a34ab to your computer and use it in GitHub Desktop.
Save pgilad/e8ffd8ce2bde81a1a375e86df77a34ab to your computer and use it in GitHub Desktop.
Convert a json file to toml
#!/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