Closed indiv0 closed 7 years ago
This one is exactly covered in readme:
#[derive(Debug, Deserialize)]
struct Project {
pub name: String,
#[serde(rename = "Item", default)]
pub items: Vec<Item>
}
Here items
maps to optional list of <Item ... />
tags.
TL;DR - always put #[serde(default)]
on potentially-missing things.
Oh. My bad, I was missing the #[serde(default)]
. Thanks!
I have a use case which involves parsing optionally-empty lists, like so:
or:
What would be the equivalent rust struct to represent this with serde-xml-rs?