https://github.com/nessex/yaml2json-rs
Command line utility (+libraries) to convert YAML to JSON.
https://github.com/nessex/yaml2json-rs
cli cli-app crates library rust rust-crates rust-library utility yaml2json
Last synced: 4 months ago
JSON representation
Command line utility (+libraries) to convert YAML to JSON.
- Host: GitHub
- URL: https://github.com/nessex/yaml2json-rs
- Owner: nessex
- License: apache-2.0
- Created: 2020-02-05T13:11:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-08T20:57:29.000Z (over 2 years ago)
- Last Synced: 2025-05-30T14:40:49.962Z (4 months ago)
- Topics: cli, cli-app, crates, library, rust, rust-crates, rust-library, utility, yaml2json
- Language: Rust
- Homepage:
- Size: 139 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# yaml2json-rs
[](https://hub.docker.com/r/nessex/yaml2json-rs)

yaml2json-rs converts one or more YAML documents into a JSON stream.
There are many implementations of this idea, with various limitations. This one aims for:
- Speed
- Multi-document support
- Error control
- selectively silence errors or output errors as JSONThis implementation relies heavily on the existing work in [Serde](https://github.com/serde-rs/serde), [yaml-rust](https://github.com/chyh1990/yaml-rust) and others to provide fast and correct serialization and deserialization. In naïve tests, this provided a significant speed improvement over other implementations, though your mileage may vary.
## Installation
Download pre-compiled binaries from the [Releases Page](https://github.com/Nessex/yaml2json-rs/releases/).
Or, install via `cargo`:
```
cargo install yaml2json-rs-bin --bin yaml2json
```Or, quickly try it out with `docker`:
```
echo "hello: world" | docker run -i nessex/yaml2json-rs:master
```## Usage
```
Utility to convert YAML files to JSONUSAGE:
./yaml2json file1.yaml file2.yamlcat file1.yaml | ./yaml2json
./yaml2json --error=json file1.yaml | jq
FLAGS:
-h, --help Prints help information
-p, --pretty
-V, --version Prints version informationOPTIONS:
-e, --error [default: stderr] [possible values: silent, stderr, json]ARGS:
... Specify the path to files you want to convert. You can also pass files via stdin instead.
```For best results when dealing with multiple documents, pass multiple files in at once by path:
```
# Be sure to use + and not \; with find
find . -name '*.yaml' -exec yaml2json {} +
```## Crates
| crate | links | description |
| --- | --- | --- |
| [yaml2json-rs-bin](https://crates.io/crates/yaml2json-rs-bin) | | A command line utility to convert YAML to JSON |
| [yaml2json-rs](https://crates.io/crates/yaml2json-rs) | [](https://docs.rs/yaml2json-rs/) | A library wrapping [serde-yaml](https://github.com/dtolnay/serde-yaml) and [serde-json](https://github.com/serde-rs/json) to convert a single YAML document to JSON |
| [yaml-split](https://crates.io/crates/yaml-split) | [](https://docs.rs/yaml-split/) | A library providing an iterator over individual YAML documents within a YAML file or stream |## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
## Support
Please consider supporting the amazing libraries that make this work:
* [serde](https://github.com/serde-rs/serde)
* [serde-yaml](https://github.com/dtolnay/serde-yaml)
* [serde-json](https://github.com/serde-rs/json)
* [anyhow](https://github.com/dtolnay/anyhow)
* [thiserror](https://github.com/dtolnay/thiserror)
* [clap](https://github.com/clap-rs/clap)