A tridirectional converter between Json, Yaml, and Toml

Public Library0.1.2updated 17 days ago814.32 KB
COPY
wapm install ken-matsui/jyt

Need help using WAPM?

chevron_rightGet started here

Commands

jyt

Files

  • Readme.md

Modules

jyt

A tridirectional converter between Json, Yaml, and Toml which supports both native and WebAssembly

Installation

You can install this using the cargo install command:

$ cargo install jyt

WebAssembly

This application also provides a wasm package. You can install it using wapm by the following command:

wapm install ken-matsui/jyt

Usage

jyt --help
jyt 0.1.0
Ken Matsui <26405363+ken-matsui@users.noreply.github.com>
A tridirectional converter between Json, Yaml, and Toml

USAGE:
    jyt <SUBCOMMAND>

OPTIONS:
    -h, --help       Print help information
    -V, --version    Print version information

SUBCOMMANDS:
    help            Print this message or the help of the given subcommand(s)
    json-to-toml    Convert Json to Toml (also as `json2toml`, `j2t`, and `jt`)
    json-to-yaml    Convert Json to Yaml (also as `json2yaml`, `j2y`, and `jy`)
    toml-to-json    Convert Toml to Json (also as `toml2json`, `t2j`, and `tj`)
    toml-to-yaml    Convert Toml to Yaml (also as `toml2yaml`, `t2y`, and `ty`)
    yaml-to-json    Convert Yaml to Json (also as `yaml2json`, `y2j`, and `yj`)
    yaml-to-toml    Convert Yaml to Toml (also as `yaml2toml`, `y2t`, and `yt`)

WebAssembly

wapm run jyt -- --help
jyt 0.1.0
Ken Matsui <26405363+ken-matsui@users.noreply.github.com>
A tridirectional converter between Json, Yaml, and Toml

USAGE:
    jyt <SUBCOMMAND>

OPTIONS:
    -h, --help       Print help information
    -V, --version    Print version information

SUBCOMMANDS:
    help            Print this message or the help of the given subcommand(s)
    json-to-toml    Convert Json to Toml (also as `json2toml`, `j2t`, and `jt`)
    json-to-yaml    Convert Json to Yaml (also as `json2yaml`, `j2y`, and `jy`)
    toml-to-json    Convert Toml to Json (also as `toml2json`, `t2j`, and `tj`)
    toml-to-yaml    Convert Toml to Yaml (also as `toml2yaml`, `t2y`, and `ty`)
    yaml-to-json    Convert Yaml to Json (also as `yaml2json`, `y2j`, and `yj`)
    yaml-to-toml    Convert Yaml to Toml (also as `yaml2toml`, `y2t`, and `yt`)

Examples

JSON -> YAML

JSON -> TOML

cat ./examples/example.json | jyt json2toml
title = "TOML Example"

[owner]
name = "Tom Preston-Werner"

[database]
server = "192.168.1.1"
ports = [8000, 8001, 8002]
connection_max = 5000
enabled = true

YAML -> JSON

cat ./examples/example.yaml | jyt y2j
{
  "title": "TOML Example",
  "owner": {
    "name": "Tom Preston-Werner"
  },
  "database": {
    "server": "192.168.1.1",
    "ports": [
      8000,
      8001,
      8002
    ],
    "connection_max": 5000,
    "enabled": true
  }
}

YAML -> TOML

cat ./examples/example.yaml | jyt yt
title = "TOML Example"

[owner]
name = "Tom Preston-Werner"

[database]
server = "192.168.1.1"
ports = [8000, 8001, 8002]
connection_max = 5000
enabled = true

TOML -> JSON

cat ./examples/example.toml | jyt tj
{
  "title": "TOML Example",
  "owner": {
    "name": "Tom Preston-Werner"
  },
  "database": {
    "server": "192.168.1.1",
    "ports": [
      8000,
      8001,
      8002
    ],
    "connection_max": 5000,
    "enabled": true
  }
}

TOML -> YAML

Advanced Usage

$ test "$(cat ./examples/example.toml)" = "$(cat ./examples/example.toml | jyt ty | jyt yj | jyt jt)"

echo $?
0

WebAssembly

TOML -> YAML

cat ./examples/example.toml | wapm run jyt -- toml2yaml
---
title: TOML Example
owner:
  name: Tom Preston-Werner
database:
  server: 192.168.1.1
  ports:
    - 8000
    - 8001
    - 8002
  connection_max: 5000
  enabled: true

... other examples are the same as native provides!

Contribution

Build

$ cargo build

Or you can directly execute the binary:

$ cargo run

WebAssembly

$ rustup target add wasm32-wasi
$ cargo build --target wasm32-wasi
$ wasmer run target/wasm32-wasi/debug/jyt.wasm

Test

This command can also test C API.

$ cargo build
$ cargo test

Publish

GitHub Releases

$ git tag v0.1.0
$ git push origin v0.1.0

crates.io

$ cargo publish

wapm.io

$ cargo build --release --target wasm32-wasi
wapm publish

<1klast week

Latest version

0.1.2

Latest updated

17 days ago

Unpackaged size

814.32 KB

License

MIT

Collaborators

    Run it in the browser