Skip to content

Instantly share code, notes, and snippets.

@mclarkson
Forked from noahcoad/yaml2json.py
Created May 15, 2017 09:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mclarkson/dbd3f56cefd589cf42b2153eb9742feb to your computer and use it in GitHub Desktop.
Save mclarkson/dbd3f56cefd589cf42b2153eb9742feb 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))