Skip to content
/ yj Public

CLI - Convert between YAML, TOML, JSON, and HCL. Preserves map order.

License

Notifications You must be signed in to change notification settings

sclevine/yj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8016400 · Dec 14, 2023

History

79 Commits
Apr 13, 2022
Apr 12, 2022
Apr 8, 2022
Apr 8, 2022
Apr 12, 2022
Apr 12, 2022
Apr 8, 2022
Mar 24, 2022
Apr 12, 2022
Jan 23, 2019
Apr 27, 2022
Apr 12, 2022
Apr 8, 2022
Apr 8, 2022
Dec 13, 2023
Dec 13, 2023
Apr 13, 2022
Apr 8, 2022
Apr 8, 2022

Repository files navigation

yj

GoDoc Tests

Packaging status

Convert between YAML, TOML, JSON, and HCL.

Preserves map order.

Format versions:

  • YAML: v1.2 (gopkg.in/yaml.v3)
  • TOML: v1.0.0 (github.com/BurntSushi/toml)
  • JSON: RFC 7159 (encoding/json)
  • HCL: v1 (github.com/hashicorp/hcl)
$ yj -h
Usage: yj [-][ytjcrneikhv]

Convert between YAML, TOML, JSON, and HCL.
Preserves map order.

-x[x]  Convert using stdin. Valid options:
          -yj, -y = YAML to JSON (default)
          -yy     = YAML to YAML
          -yt     = YAML to TOML
          -yc     = YAML to HCL
          -tj, -t = TOML to JSON
          -ty     = TOML to YAML
          -tt     = TOML to TOML
          -tc     = TOML to HCL
          -jj     = JSON to JSON
          -jy, -r = JSON to YAML
          -jt     = JSON to TOML
          -jc     = JSON to HCL
          -cy     = HCL to YAML
          -ct     = HCL to TOML
          -cj, -c = HCL to JSON
          -cc     = HCL to HCL
-n     Do not covert inf, -inf, and NaN to/from strings (YAML or TOML only)
-e     Escape HTML (JSON out only)
-i     Indent output (JSON or TOML out only)
-k     Attempt to parse keys as objects or numeric types (YAML out only)
-h     Show this help message
-v     Show version

Installation

Homebrew

The yj CLI is available via Homebrew:

brew install yj

Manual

Binaries for macOS, Linux, and Windows are attached to each release.

Docker

yj is also available as a Docker image.

Go Package

Packages contained in this repo may also be used to convert all supported data formats to a normalized tree of ordered Go objects.

See godoc for details.

NOTE: The current Go API should not be considered stable.