//home | my other blog | github | twitter | about | legal

Manipulating yaml data on the CLI

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 ...