Last active
February 15, 2024 02:17
-
-
Save giner/c889135c7a7f6b53f3c90142556b1205 to your computer and use it in GitHub Desktop.
How-to YAML
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
# Usage: | |
# source lib_y2j.sh | |
# cat some.yml | y2j | |
# cat some.yml | ys2j | |
# y2j some.yml | |
# ys2j some.yml | |
# Reading a single YAML document | |
y2j () { ruby -r yaml -r json -e 'puts JSON.pretty_generate(YAML.load(ARGF))' -- "$@"; } | |
# Reading multiple YAML documents (e.g. `helm template ...`) | |
ys2j () { ruby -r yaml -r json -e 'puts JSON.pretty_generate(YAML.load_stream(ARGF))' -- "$@"; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment