Convert Between json and yaml With yq

One of my experimental projects involves fetching data from GitHub with gh, editing the output, and then posting the results back to GitHub. It’s easy to produce json output from gh, but who wants to edit in json? I’d rather use yaml. Enter the yq tool.

It works much like jq, but also handles conversions from json to yaml and vice versa:

echo '{"here":"there"}' | yq -pj -oy
echo 'here: there' | yq -py -oj

So now I can convert to yaml, edit there, and convert back to json before posting t the API.

This is my only use of yq so far. I use jq elsewhere, and see yq as useful mainly for this type of conversion. One more problem solved!