-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to pretty-print with serde? #361
Comments
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 |
Still 2 doc-test failures
Still 2 doc-test failures
Can you please explain how it's meant to work? I didn't find any API for pretty-print serialization. thanks! |
Create |
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}"); |
I was expecting a |
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?
The text was updated successfully, but these errors were encountered: