Skip to content

Instantly share code, notes, and snippets.

@mboersma
Last active March 8, 2023 10:31
Show Gist options
  • Save mboersma/1329671 to your computer and use it in GitHub Desktop.
Save mboersma/1329671 to your computer and use it in GitHub Desktop.
JSON to YAML one-liner
python3 -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j))'
@radekdvorak72
Copy link


test:
- xxx: aa

@techsolx
Copy link

Thanks! Here is the python3 version:
python3 -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print(yaml.safe_dump(j))'

@mboersma
Copy link
Author

Thanks @techsolx! Obviously the python3 version should be the version at this point, so I'll update this one-liner.

Here is the old python 2 version for reference:

python -c 'import sys, yaml, json; j=json.loads(sys.stdin.read()); print yaml.safe_dump(j)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment