Skip to content

Instantly share code, notes, and snippets.

Created September 26, 2016 16:50
Show Gist options
  • Save anonymous/836193b4ad82c5a33e1f77088dc23ac2 to your computer and use it in GitHub Desktop.
Save anonymous/836193b4ad82c5a33e1f77088dc23ac2 to your computer and use it in GitHub Desktop.
JSON to YAML converter.
#!/bin/sh
JFILE=$1
python -c 'import sys, yaml, json; yaml.safe_dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)' < $JFILE
## usage
## $ py2j.sh my-cloudformation-template.json > my-cloudformation-template.yaml
## see also py2j.sh:
## #!/bin/sh
##
## YFILE=$1
##
## python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout)' < $YFILE |jq '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment