Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix deserialize error with invalid map type

appflowy47f3a187c4d8
diff --git a/rust-lib/flowy-ot/src/core/attributes/attributes_serde.rs b/rust-lib/flowy-ot/src/core/attributes/attributes_serde.rs
index 659a384daf..f277de6dfe 100644
--- a/rust-lib/flowy-ot/src/core/attributes/attributes_serde.rs
+++ b/rust-lib/flowy-ot/src/core/attributes/attributes_serde.rs
@@ -71,7 +71,6 @@ impl<'de> Deserialize<'de> for Attributes {
{
let mut attributes = Attributes::new();
while let Some(key) = map.next_key::<AttributeKey>()? {
- log::warn!("{:?}", key);
let value = map.next_value::<AttributeValue>()?;
attributes.add_kv(key, value);
}
@@ -103,10 +102,7 @@ impl<'de> Deserialize<'de> for AttributeValue {
struct AttributeValueVisitor;
impl<'de> Visitor<'de> for AttributeValueVisitor {
type Value = AttributeValue;
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- //
- formatter.write_str("bool, usize or string")
- }
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("bool, usize or string") }
fn visit_bool<E>(self, value: bool) -> Result<Self::Value, E>
where
E: de::Error,
@@ -190,6 +186,16 @@ impl<'de> Deserialize<'de> for AttributeValue {
{
Ok(AttributeValue(None))
}
+
+ fn visit_map<A>(self, map: A) -> Result<Self::Value, A::Error>
+ where
+ A: MapAccess<'de>,
+ {
+ // https://github.com/serde-rs/json/issues/505
+ let mut map = map;
+ let value = map.next_value::<AttributeValue>()?;
+ Ok(value)
+ }
}
deserializer.deserialize_any(AttributeValueVisitor)