python-scripts/scripts/29_json_to_yaml.py

17 lines
334 B
Python
Raw Normal View History

2015-10-11 17:28:50 +02:00
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))