5 个版本
0.2.0 | 2022 年 8 月 1 日 |
---|---|
0.1.3 | 2022 年 6 月 19 日 |
0.1.2 | 2022 年 5 月 9 日 |
0.1.1 | 2022 年 4 月 25 日 |
0.1.0 | 2022 年 3 月 1 日 |
#540 在 WebAssembly
每月 32 次下载
24KB
449 行
jyt

支持本地和 WebAssembly 的 Json, Yaml, Toml 之间的双向转换器
安装
您可以使用 cargo install
命令安装此软件
$ cargo install jyt
WebAssembly
此应用程序还提供 wasm 包。您可以使用以下命令通过 wapm
安装它
$ wapm install ken-matsui/jyt
用法
%%{init: {"flowchart" : { "curve" : "linear" } } }%%
graph LR;
JSON --> |$ jyt jy|YAML
JSON --> |$ jyt jt|TOML
YAML --> |$ jyt yt|TOML
YAML --> |$ jyt yj|JSON
TOML --> |$ jyt ty|YAML
TOML --> |$ jyt tj|JSON
$ jyt --help
jyt 0.1.0
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
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`)
示例
JSON -> YAML
$ cat ./examples/example.json | jyt json-to-yaml
title: TOML Example
owner:
name: Tom Preston-Werner
database:
server: 192.168.1.1
ports:
- 8000
- 8001
- 8002
connection_max: 5000
enabled: true
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
$ cat ./examples/example.toml | jyt ty
title: TOML Example
owner:
name: Tom Preston-Werner
database:
server: 192.168.1.1
ports:
- 8000
- 8001
- 8002
connection_max: 5000
enabled: true
高级用法
$ 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
... 其他示例与本地提供的相同!
贡献
构建
$ cargo build
或者您可以直接执行二进制文件
$ cargo run
WebAssembly
$ rustup target add wasm32-wasi
$ cargo build --target wasm32-wasi
$ wasmer run target/wasm32-wasi/debug/jyt.wasm
测试
此命令还可以测试 C API。
$ cargo build
$ cargo test
发布
GitHub 发布
$ git tag v0.1.0
$ git push origin v0.1.0
crates.io
$ cargo publish
wapm.io
$ rustup target add wasm32-wasi
$ cargo build --release --target wasm32-wasi
$ wapm publish
依赖
~2.8–5MB
~91K SLoC