yj

Crates.ioyj
lib.rsyj
version1.2.4
sourcesrc
created_at2018-12-19 23:56:56.665849
updated_at2024-06-05 11:04:28.655172
descriptionCommand line tool that converts YAML to JSON
homepagehttps://github.com/bruceadams/yj
repositoryhttps://github.com/bruceadams/yj
max_upload_size
id102833
size47,523
golem-developers (github:golemcloud:golem-developers)

documentation

README

YJ - YAML to JSON

Build Status

Simple command line tool to convert a YAML input file into a JSON output file.

How to, etc.

Built in help

% yj --help
Command line tool that converts YAML to JSON

Usage: yj [OPTIONS] [INPUT]

Arguments:
  [INPUT]  Input YAML file name. Defaults to stdin

Options:
  -c, --compact          Use compact formatting for the JSON output
  -y, --yaml             Format the output as YAML instead of JSON
  -j, --json             Parse the input as JSON. For most use cases, this
                         option makes no difference. Valid JSON is valid
                         YAML, so JSON input will (should?) parse
                         correctly even when being handled with the YAML
                         parser. Use this option when you want failure
                         (instead of weird results) when the input is
                         invalid JSON
  -o, --output <OUTPUT>  Output file name for the JSON. Defaults to stdout
  -h, --help             Print help information
  -V, --version          Print version information

Installing

Local build and install with cargo:

$ cargo install yj

Prebuilt binaries are available on Github releases for some common platforms.

On macOS, the prebuilt binary can be installed using Homebrew. Unfortunately, Homebrew picked up a different utility with the name yj after I chose that name here. So, a simple brew install yj gets that tool, not this one 😞.

$ brew tap bruceadams/utilities
$ brew install bruceadams/utilities/yj

Alternatively on macOS, you may also install yj using MacPorts:

$ sudo port selfupdate
$ sudo port install yj

Minimal Docker images are available on Docker Hub:

$ docker pull bruceadams/yj

Example runs

$ cat .travis.yml
language: rust
os:
  - linux
  - osx
  - windows
rust:
  - stable
  - beta
  - nightly
matrix:
  allow_failures:
    - rust: nightly
  fast_finish: true
$ yj .travis.yml
{
  "language": "rust",
  "os": [
    "linux",
    "osx",
    "windows"
  ],
  "rust": [
    "stable",
    "beta",
    "nightly"
  ],
  "matrix": {
    "allow_failures": [
      {
        "rust": "nightly"
      }
    ],
    "fast_finish": true
  }
}
$ echo pi: 3.1415926 | yj
{
  "pi": 3.1415926
}
$ echo pi: 3.1415926 | yj -c
{"pi":3.1415926}$

Build

Build it your self with Rust 2018, which needs a recent installation of Rust. Get Rust installed from https://rustup.rs/.

cargo build
Commit count: 152

cargo fmt