Python: Convert JSON to YAML
less than 1 minute read
Use the following code to convert a JSON file into a YAML file
#!/usr/bin/env python
import json
import yaml
with open('my_json', 'r') as f:
json_data = json.loads(f.read())
with open('my_yaml', 'w+') as f:
f.write(yaml.dump(json_data))
Comments