Skip to content

Instantly share code, notes, and snippets.

@haarcuba
Created February 3, 2023 15:15
Show Gist options
  • Save haarcuba/6d342eae2c6e7a330d401a4bcf47b24d to your computer and use it in GitHub Desktop.
Save haarcuba/6d342eae2c6e7a330d401a4bcf47b24d to your computer and use it in GitHub Desktop.
yaml utils
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