Closed benjaminSchilling33 closed 2 years ago
Hey I'd use Option<whatever>
for the items that are not always in every single prop
Something like:
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Prop {
#[serde(default)]
getlastmodified: Option<String>,
#[serde(default)]
getetag: Option<String>,
#[serde(default)]
getcontentlength: i64,
#[serde(default)]
getcontenttype: String,
#[serde(default, rename(deserialize = "quota-used-bytes"))]
quota_used_bytes: Option<i64>,
#[serde(default, rename(deserialize = "quota-available-bytes"))]
quota_available_bytes:Option<i64>,
}
thanks, that helped!
I'm trying to deserialize webdav responses from a Nextcloud instance.
Currently the parsing failes due to the following error:
UnexpectedToken { token: "EndElement", found: "Characters" }
I'm not 100% sure what causes this problem, but I would expect that it is caused by the following issue:
I receive the response as XML that contains an element that can have child elements, in this case
prop
with varying child elements, like the following.How would you set up the structs with their fields and the corresponding serde annotations to parse this kind of data?
Example XML:
My current approach: