Skip to content

Instantly share code, notes, and snippets.

@noahcoad
Last active December 27, 2019 22:46
Show Gist options
  • Save noahcoad/51934724e0896184a2340217b383af73 to your computer and use it in GitHub Desktop.
Save noahcoad/51934724e0896184a2340217b383af73 to your computer and use it in GitHub Desktop.
Python to Convert yaml to json
# convert yaml to json
# pip3 install pyyaml
# http://pyyaml.org/wiki/PyYAMLDocumentation
# py3 yaml2json.py < ~/code/manpow/homeland/heartland/puphpet/config.yaml
# gist https://gist.github.com/noahcoad/51934724e0896184a2340217b383af73
import yaml, json, sys
sys.stdout.write(json.dumps(yaml.load(sys.stdin), sort_keys=True, indent=2))
@JoelFeiner
Copy link

You left out a colon after mgmt on the 4th line.

@ravibhure
Copy link

better to use YAMLlint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment