python-scripts/29_json_to_yaml.py
2015-10-15 22:51:07 +01:00

17 lines
334 B
Python
Executable File

import sys
import json
import yaml
"""
Example usage:
$ python 29_json_to_yaml.py 29_json_test.json
"""
# load json data
json_data = json.loads(open(sys.argv[1]).read())
# convert unicode to string
converted_json_data = json.dumps(json_data)
# output yaml
print(yaml.dump(yaml.load(converted_json_data), default_flow_style=False))