Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bruceadams/yj
Command line tool that converts YAML to JSON
https://github.com/bruceadams/yj
command-line-tool hacktoberfest json yaml
Last synced: 5 days ago
JSON representation
Command line tool that converts YAML to JSON
- Host: GitHub
- URL: https://github.com/bruceadams/yj
- Owner: bruceadams
- License: apache-2.0
- Created: 2018-12-19T23:19:51.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-16T10:37:41.000Z (3 months ago)
- Last Synced: 2024-10-05T14:47:53.219Z (about 1 month ago)
- Topics: command-line-tool, hacktoberfest, json, yaml
- Language: Rust
- Homepage:
- Size: 174 KB
- Stars: 109
- Watchers: 5
- Forks: 11
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# YJ - YAML to JSON
[![Build Status](https://api.cirrus-ci.com/github/bruceadams/yj.svg)](https://cirrus-ci.com/github/bruceadams/yj)Simple command line tool to convert a YAML input file into a JSON output file.
## How to, etc.
### Built in help
```bash
% yj --help
Command line tool that converts YAML to JSONUsage: yj [OPTIONS] [INPUT]
Arguments:
[INPUT] Input YAML file name. Defaults to stdinOptions:
-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 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`:
```bash
$ cargo install yj
```Prebuilt binaries are available on
[Github releases](https://github.com/bruceadams/yj/releases)
for some common platforms.On macOS, the prebuilt binary can be installed using
[Homebrew](https://brew.sh). 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 😞.```bash
$ brew tap bruceadams/utilities
$ brew install bruceadams/utilities/yj
```Alternatively on macOS, you may also install `yj` using [MacPorts](https://www.macports.org):
```bash
$ sudo port selfupdate
$ sudo port install yj
```Minimal Docker images are available on
[Docker Hub](https://cloud.docker.com/repository/docker/bruceadams/yj):```bash
$ docker pull bruceadams/yj
```### Example runs
```bash
$ 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/.```bash
cargo build
```