use serde::Deserialize;
use std::collections::HashMap;
#[derive(Debug, Clone, Deserialize)]
#[serde(untagged)]
pub enum FactItem {
Str(String),
Map(HashMap<String, serde_json::Value>),
}
impl FactItem {
pub fn into_string(self) -> Option<String> {
match self {
FactItem::Str(s) => Some(s),
FactItem::Map(map) => map
.get("text")
.or_else(|| map.get("fact"))
.or_else(|| map.get("value"))
.or_else(|| map.get("content"))
.or_else(|| map.get("description"))
.and_then(|v| v.as_str())
.map(|s| s.to_string()),
}
}
}