CLI - Convert between YAML, TOML, JSON, and HCL. Preserves map order.
-t
flag now parses/emits TOML v1.0.0 instead of v1.0.0-rc.1.
gopkg.in/yaml.v3
is upgraded to 496545a.github.com/BurntSushi/toml
(v1.1.0), fixing several upstream bugs.Available for macOS via Homebrew:
$ brew install yj
Binaries for Linux, macOS, and Windows are attached below.
Alternatively, you may also install yj via go get
:
$ go get github.com/sclevine/yj/[email protected]
yj
is also available as a Docker image.
-t
flag now parses/emits TOML v1.0.0-rc.1 instead of v0.4.0.
-v
flag now prints the version of yj (#9).-n
flag is now enabled by default when converting between formats that both support NaN
, Inf
, etc.gopkg.in/yaml.v3
instead of gopkg.in/yaml.v2
.github.com/pelletier/go-toml
instead of github.com/BurntSushi/toml
.Available for macOS via Homebrew:
$ brew install yj
Binaries for Linux, macOS, and Windows are attached below.
Alternatively, you may also install yj via go get
:
$ go get github.com/sclevine/yj
Features
-i
flag to indent JSON and TOML output (#4).Breaking Changes
TOML output is now unindented by default. Pass -i
to use the previous behavior.
BurntSushi/toml applies more aggressive indentation compared to the examples in the TOML spec, and the TOML spec does not recommend (or recommend against) indenting. Opt-in indentation seems preferable.
opal:yj stephen$ yj -h
Usage: yj [-][rcjenkh]
Converts stdin from JSON/YAML to YAML/JSON.
-r Convert JSON to YAML instead of YAML to JSON
-c Use CandiedYAML parser instead of GoYAML parser
-n Do not covert Infinity, -Infinity, and NaN to/from strings
-h Show this help message
YAML to JSON options:
-e Escape HTML in JSON output (ignored for JSON to YAML)
JSON to YAML (-r) options:
-y Use a YAML decoder instead of a JSON decoder to parse JSON
-k Attempt to parse keys as JSON objects/numbers