Open
Description
I'm trying to deserialize some dictionary defitnitions and came across this one which contains mixed multiple tags with normal string (html text formatting).
<div style="margin-left:2em"><b>1</b> 〔学業・技術などの能力判定〕 an examination; a test; 《口》 an exam; 《米》 a quiz 《<i>pl</i>. quizzes》.</div>
I looked around in serde-xml-rs tests and tried this solution which seems to be close but it doesn't quite work
#[derive(Debug, Deserialize, PartialEq)]
struct DivDefinition {
style: String,
#[serde(rename = "$value")]
definition: Vec<MyEnum>,
}
#[derive(Debug, Deserialize, PartialEq)]
enum MyEnum {
b(String),
#[serde(rename = "$value")]
String,
i(String),
}
The error I'm getting is:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("unknown variant `〔学業・技術などの能力判定〕 an examination; a test; 《口》 an exam; 《米》 a quiz 《`, expected one of `b`, `$value`, `i`")'
I can make it work for now by not using MyEnum
and just use definition: Vec<String>
, but then I wouldn't know which text is bold and which is italic.
How can I properly deserialize this?