Using YQ to convert JSON to YAML
Raise your hand if you like reading JSON? Exactly. YAML isn't appreciably better (I don't know if it's just me but working out space and dashes and indents in YAML is not clear at all) but it is a little bit better. Far fewer braces and quote marks.
And given the two are often used interchangable (particularly in AWS) you often need to convert one to the other. There are a bunch of ways to do this, googling it will reveal many results, but this is the easiest in my opinion.
For anyone who has worked with JSON responses they'd be familiar with jq, an amazing little tool that parses JSON. yq is its YAML affiliated brother.
Foy my Ubuntu instance it was as easy as going to get the latest version from https://github.com/mikefarah/yq/releases/ (4.9.6 at the time of this writing) and running:
version=4.9.6
wget https://github.com/mikefarah/yq/releases/download/v${version}/yq_linux_amd64.tar.gz -O - |\
tar xz && sudo mv yq_linux_amd64 /usr/bin/yq
If you use a package manager check the version as the formatting for version 3 commands is quite different
cloud9@cloud9-host:/tmp$ yq -V
yq version 4.9.6
And then yq eval -P filename.json > newfilename.yaml and boom! YAML! An example below:
cloud9@cloud9-host:/tmp$ cat jsn.json
{"a":"Easy! as one two three","b":{"c":2,"d":[3,4]}}
cloud9@cloud9-host:/tmp$ yq eval -P jsn.json > jsn.yaml
cloud9@cloud9-host:/tmp$ cat jsn.yaml
a: Easy! as one two three
b:
c: 2
d:
- 3
- 4
The v3 format is yq -y '.' filename.json > newfilename.yaml but you'll want to test that.
There are also docker images, loads of architectures (eg. this won't work on raspberry pi as specified) but will work on your run of the mill x64 server (for a Pi get the arm64 version not amd64 but I'll leave it to you to experiment)