Closed troelsarvin closed 2 years ago
Pretty-printing not supported yet, PR is welcome. Be noted, however, that I plan a big rework of a serializer in the coming months
When #490 will be merged, pretty-print will work
When #490 will be merged, pretty-print will work
Can you please explain how it's meant to work? I didn't find any API for pretty-print serialization.
thanks!
For anyone who needs a quick example of adding indentation when do serializing
use serde::Serialize;
use quick_xml::se::Serializer;
#[derive(Debug, PartialEq, Serialize)]
struct Struct {
question: String,
answer: u32,
}
let data = Struct {
question: "The Ultimate Question of Life, the Universe, and Everything".into(),
answer: 42,
};
let mut buffer = String::new();
let mut ser = Serializer::new(&mut buffer);
ser.indent(' ', 2);
data.serialize(ser).unwrap();
println!("{buffer}");
@noguxun, feel free to make a PR that improves documentation (example for indent
and maybe a mention in Serializer
doc)
I was expecting a to_string_pretty(options: ToStringPrettyOptions)
. I believe that API is similar to other serde
format libraries.
Hello,
I have the code below; when it runs, it results in the following output:
I would like to print it in a prettyfied way, i.e. with indention and line breaks following the XML structure. How can that be done?