pub fn yaml_to_json(yaml: &str) -> Result<String, Box<dyn Error>>Expand description
Converts a YAML sequence of mappings into a JSON array of objects.
This function parses YAML with a strict schema to avoid the “Norway problem”:
yes, no, on, off, y, n are treated as strings under YAML 1.2
semantics. Nested sequences or mappings cause an error because they cannot
round-trip losslessly through flat CSV/TSV.
§Errors
Returns an error if the YAML is not a sequence of mappings, contains nested values, or if JSON serialization fails.
§Examples
use sheeter_engine::yaml_to_json;
let yaml = "- name: Alice\n age: '30'\n- name: Bob\n age: '25'\n";
let json = yaml_to_json(yaml).unwrap();
assert_eq!(json, r#"[{"name":"Alice","age":"30"},{"name":"Bob","age":"25"}]"#);