YAML JSON

YAML

Variables
somewhere: 
  # define a variable using &
  data-dir: &data-dir path/to/dir

somewhere-else:
  # use a variable using *
  input-dir: *data-dir

JSON

jq

sudo apt install jq
https://www.baeldung.com/linux/jq-command-json
echo '{"fruit":{"name":"apple","color":"green","price":1.20}}' | jq '.'
jq '.' myfile.json
curl http://api.open-notify.org/iss-now.json | jq '.'

# .field operator
jq '.fruit' fruit.json

# chain .field operator
jq '.fruit.color' fruit.json

# retrieve multiple keys, separate them using a comma
jq '.fruit.color,.fruit.price' fruit.json

# handle special characters
echo '{ "with space": "hello" }' | jq '."with space"'