Skip to content

Instantly share code, notes, and snippets.

@mpontillo
Created May 30, 2017 17:42
Show Gist options
  • Save mpontillo/14ec5fee876bb29987542354d0886cb7 to your computer and use it in GitHub Desktop.
Save mpontillo/14ec5fee876bb29987542354d0886cb7 to your computer and use it in GitHub Desktop.
Python script to input YAML and output "pretty" JSON.
#!/usr/bin/env python3
import sys
import json
import yaml
if __name__ == "__main__":
data = sys.stdin.read()
obj = yaml.safe_load(data)
print(json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': ')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment