You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The original problem is that my format is not completely self-describing because it does not encode field types, and I need to rely on the types to be inferred from the target struct when deserializing. However, I found that deserialize_any was being called on my Deserializer when I used the #[serde(flatten)] attribute.
I have tried to reduce this problem to the minimal necessary code, in this gist. The problem shows itself by the fact that deserialize_map is called in the failing test, but is not called in the passing test.
Deserializing to this struct works (does not call deserialize_map):
The text was updated successfully, but these errors were encountered:
peterjoel
changed the title
Deserializing to a flattened struct calls deserialize_map, while deserializing to an already-flat struct does not
Deserializing to a flattened struct calls deserialize_map, but deserializing to an already-flat struct does not
May 20, 2019
Seems to be related to RReverser/serde-xml-rs#112 as well: it's hard to implement a proper deserialiser, which works with #[serde(flatten)], for formats without strict schema (like xml).
The original problem is that my format is not completely self-describing because it does not encode field types, and I need to rely on the types to be inferred from the target struct when deserializing. However, I found that
deserialize_any
was being called on my Deserializer when I used the#[serde(flatten)]
attribute.I have tried to reduce this problem to the minimal necessary code, in this gist. The problem shows itself by the fact that
deserialize_map
is called in the failing test, but is not called in the passing test.Deserializing to this struct works (does not call
deserialize_map
):But deserializing these to structs results in a call to
deserialize_map
:I also checked that both structures expect the following deserialize tokens:
Perhaps I have this wrong, but I would expect this to indicate that both visitors should interact with the deserializer identically.
Full code: https://gist.github.com/peterjoel/a41363fea48c4cb529e4a4bf8421ec20
The text was updated successfully, but these errors were encountered: