yaml-2-json.py 471 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. import yaml
  3. import json
  4. import sys
  5. from pprint import pprint
  6. filename = sys.argv[1]
  7. with open(filename) as fp:
  8. data = yaml.safe_load(fp)
  9. # pprint(data)
  10. newfile = filename
  11. newfile = newfile.replace(".yaml", ".json")
  12. with open(newfile, 'w') as fp:
  13. json.dump(data, fp, indent=2)
  14. # Cleaning the json:
  15. # jq 'del( .meta[ "density", "trade" ])' viper-A-bugz.json
  16. # Pretty-print the json:
  17. # jq . viper-A-bugz.json > viper-A-bugz-pretty.json