Created
November 16, 2012 02:36
-
-
Save lorin/4083433 to your computer and use it in GitHub Desktop.
Convert from json to yaml
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 python | |
""" Convert json to YAML | |
Usage: json2yaml.py [infile] | |
""" | |
import args | |
import json | |
import sys | |
import yaml | |
def main(fin=sys.stdin, fout=sys.stdout): | |
data = json.load(fin) | |
yaml.safe_dump(data, stream=fout, default_flow_style=False, indent=4) | |
if __name__ == '__main__': | |
if args.files: | |
fname, = args.files | |
fin = open(fname) | |
else: | |
fin = sys.stdin | |
main(fin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment