YAML helper tool — validate yaml and convert it to json.
jyaml validate [yaml] # validate, silent on success
jyaml tojson [yaml] # convert to json
If no YAML argument is given, the input is read from stdin.
jyaml validate config.yaml && echo "valid"
jyaml tojson 'a: 1'
# {"a":1}
jyaml tojson config.yaml | jjson pretty
jyaml tojson -p config.yaml > config.json # pretty output
cat values.yaml | jyaml tojson | jq .
# multi documents are not merged: only the first is loaded
Notes:
1: one) are converted to strings.null / ~ and empty input convert to null.tojson: -p, --pretty pretty print the json-t, --text-file FILE, -c, --charset, -v, --verbose
(see jregex for the common options)Exit codes: 0 success, 2 invalid yaml.
brew tap mhus/jknife
brew install jyaml
Or download the binary for your platform from the releases.