The JSON array mixes string
and object
like
{
"text": [
{
"type": "mention_name",
"text": "Uopju Mnohu🎀 ",
"user_id": 5149962590
},
" has been banned! Reason: ",
{
"type": "text_link",
"text": "CAS ban",
"href": "https://cas.chat/query?u=5149962590"
},
"."
]
}
I tried something like but it does not work.
#[derive(Debug, Clone, Serialize, Deserialize)]
struct Text {
text: String,
r#type: String,
user_id: Option<i64>,
href: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
enum TextItem { // ???
String(String),
Text(Text),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
struct Message {
text: Vec<TextItem>
}
Thanks.