Created
February 3, 2023 15:15
-
-
Save haarcuba/6d342eae2c6e7a330d401a4bcf47b24d to your computer and use it in GitHub Desktop.
yaml utils
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
function yaml_validate { | |
python -c 'import sys, yaml, json; yaml.safe_load(sys.stdin.read())' | |
} | |
function yaml2json { | |
python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read())))' | |
} | |
function yaml2json_pretty { | |
python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read()), indent=2, sort_keys=False))' | |
} | |
function json_validate { | |
python -c 'import sys, yaml, json; json.loads(sys.stdin.read())' | |
} | |
function json2yaml { | |
python -c 'import sys, yaml, json; print(yaml.dump(json.loads(sys.stdin.read())))' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment