Skip to content

Instantly share code, notes, and snippets.

@giner
Last active February 15, 2024 02:17
Show Gist options
  • Save giner/c889135c7a7f6b53f3c90142556b1205 to your computer and use it in GitHub Desktop.
Save giner/c889135c7a7f6b53f3c90142556b1205 to your computer and use it in GitHub Desktop.
How-to YAML
# 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