Skip to content

Instantly share code, notes, and snippets.

@Ciantic
Created February 3, 2021 16:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ciantic/3788b61297c3dd8ea79233f161ecf84f to your computer and use it in GitHub Desktop.
Save Ciantic/3788b61297c3dd8ea79233f161ecf84f to your computer and use it in GitHub Desktop.
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