If you have ruby
and jq
installed, it’s as easy as adding a function to your ~/.bashrc
(or .kshrc
):
function yaml2json()
{
ruby -ryaml -rjson -e \
'puts JSON.pretty_generate(YAML.load(ARGF))' $*
}
And then yaml2json document.yaml|jq ...