pub fn parse_yaml<T>(
text: &str,
options: Option<FormatOptions>,
) -> Result<Formatted<T>, Error>where
T: DeserializeOwned,Expand description
Parses a YAML string into a value, capturing outer whitespace only.
Examples found in repository?
examples/parse_yaml.rs (line 16)
6fn main() {
7 let text = r#"
8
9name: c12-parser
10version: 1.0.0
11keywords:
12 - config
13 - parser
14"#;
15
16 let formatted = parse_yaml::<Value>(text, None).expect("parse");
17 println!(
18 "Parsed: {} {}",
19 formatted.value["name"], formatted.value["version"]
20 );
21 println!("Keywords: {:?}", formatted.value["keywords"]);
22
23 let out = stringify_yaml(&formatted, None).expect("stringify");
24 println!("Stringify:\n{}", out);
25}