-
Notifications
You must be signed in to change notification settings - Fork 253
text data in tag contents #868
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
Comments
You could introduce intermediate type to accept text and ignore it. Something like fn deserialize_values<'de, D>(deserializer: D) -> Result<Option<Vec<Value>>, D::Error>
where D: Deserializer<'de>,
{
#[derive(Deserialize)]
enum Workaround {
#[serde(rename = "value")]
Value(Value),
#[serde(rename = "$text")]
Text,
}
let data: Option<Vec<Workaround>> = Deserialize::deserialize(deserializer)?;
// convert to Option<Vec<Value>> by skipping Workaround::Text elements
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename = "key")]
pub struct Key {
#[serde(rename = "$value", deserialize_with = "deserialize_values")]
pub values: Option<Vec<Value>>,
} Note, that |
this is a possibility, thank you, I do this way in another problematic XML node, but there was a Choice enum from the beginning I wonder why I have to specify this in |
This is a bug. It should skip texts when deserialize sequences of elements with fixed name. The fix is coming |
failures: issue868
failures: issue868
failures: issue868
failures: serde-de-seq: fixed_name::variable_size::text_and_value variable_name::variable_size::text_and_value serde-issues: issue868
Uh oh!
There was an error while loading. Please reload this page.
I have a data file which I cannot (shouldn't ask to) change:
When I deserialize using quick-xml & serde, I have an error, with this
d
, which I'd love to ignore completelyError I have and I'd like to ignore is
Error: invalid type: string "d", expected struct Value
The text was updated successfully, but these errors were encountered: