/ yaml2json
yaml2json
1 #!/usr/bin/env python3 2 # 3 # YAML to JSON conversion script 4 # Based on https://www.geeksforgeeks.org/convert-yaml-to-json/ 5 # 6 # This script takes a YAML file as the first arg, converts the 7 # YAML content to JSON, and outputs the converted JSON content 8 # to stdout. 9 10 import json 11 import sys 12 13 import yaml 14 15 try: 16 print(json.dumps(yaml.load(open(sys.argv[1]), Loader=yaml.FullLoader), indent=4)) 17 except IndexError: 18 print("YAML file must be supplied as first arg") 19 except FileNotFoundError: 20 print("YAML file not found")