Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
YAML to JSON with Rust
// Yaml to JSON with Rust
// Dependencies serde_yaml and serde_json
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3ddd4d9a65f03b717eeb1258299e9503
fn main() {
let json_value: serde_json::Value = serde_yaml::from_str(&"
---
test: some value here
another: value here
third:
- array
- another
".replace(" ", "")).unwrap();
println!("{}", serde_json::to_string_pretty(&json_value).unwrap());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment