Skip to content

Instantly share code, notes, and snippets.

@relaxdiego
Last active October 22, 2021 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save relaxdiego/6ad236492003b6225274123284883916 to your computer and use it in GitHub Desktop.
Save relaxdiego/6ad236492003b6225274123284883916 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Usage: ./yaml-to-json.sh | jq .
#
file=$1
if ! pip show pyyaml >/dev/null; then
echo "PyYAML needs to be installed"
exit 1
fi
python3 -c "import sys,yaml,json; print(json.dumps(yaml.safe_load(sys.stdin)))" < "$file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment