convert_yml_to_json.py 250 B

1234567891011121314
  1. import yaml
  2. import json
  3. import sys
  4. yamlf = sys.argv[1]
  5. assert yamlf.endswith(".yml")
  6. with open(yamlf, 'r') as rf:
  7. yaml_data = yaml.safe_load(rf)
  8. jsonf = yamlf[:-4] + ".json"
  9. with open(jsonf, 'w') as wf:
  10. json.dump(yaml_data, wf, indent=4)