use quickxml_to_serde::xml_string_to_json as xml2json;
use serde_json::{self, json, Value};
fn main() -> Result<(), ::std::io::Error> {
let xml = r#"<xml><tag1 att1 = "test">
<tag2><!--Test comment-->Test</tag2>
<tag2>
Test 2
</tag2>
</tag1></xml>"#.into();
let json: Value = xml2json(xml);
println!("{:?}", json);
println!("{:?}", json.to_string());
Ok(())
}
评论区
写评论quickxml_to_serde用来将xml转换为serde_json能干活:
就差一个serde_json_to_xml.