- pub fn serialize(&self) -> String {
- format!(r#"{{
- "id": "{}",
- "created_on": {}
-}}"#, self.id, self.created_on)
- }
-
- pub fn deserialize(input: &str) -> Option<Metadata> {
- let clean_input = input
- .chars()
- .filter(|c| !c.is_whitespace())
- .collect::<String>();
-
- let id = Metadata::read_field(&clean_input, "id")?;
- let created_on = Metadata::read_field(&clean_input, "created_on")
- // createdOn kept for compatibility with blog < 7.0.0
- .or_else(|| Metadata::read_field(&clean_input, "createdOn"))?;
-
- Some(Metadata {
- id,
- created_on: created_on.parse().ok()?
- })
- }
-