Last active
July 31, 2023 12:34
-
-
Save mboersma/1329669 to your computer and use it in GitHub Desktop.
YAML to JSON one-liner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python3 -c 'import sys, yaml, json; y=yaml.safe_load(sys.stdin.read()); print(json.dumps(y))' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python3 -c 'import sys, yaml, json; json.dump(yaml.safe_load(sys.stdin), sys.stdout, indent=4)'
I usually want the pretty-print functionality.
If you only want pretty-print, and don't need JSON...
python3 -c 'import sys, yaml; yaml.dump(yaml.safe_load(sys.stdin), sys.stdout)'