Skip to content

Instantly share code, notes, and snippets.

@ltpitt
Created April 8, 2022 09:21
Show Gist options
  • Save ltpitt/836c66f37ec493e672eaa646327a2309 to your computer and use it in GitHub Desktop.
Save ltpitt/836c66f37ec493e672eaa646327a2309 to your computer and use it in GitHub Desktop.
Simple cli tool to translate a YAML file to JSON
import yaml
import json
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('yaml', help='Enter YAML file path')
args = parser.parse_args()
with open(args.yaml) as infile:
os_list = yaml.load(infile, Loader=yaml.FullLoader)
print(json.dumps(os_list, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment