Sergio0694 / BinaryPack

The fastest and most memory efficient binary serialization library for .NET Standard 2.1, powered by dynamic IL generation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deserializing Dictionary<string, object>

lm-adruschel opened this issue · comments

In dynamic runtime very often you need to store values in Dictionary<string, object> variables. These can be serialized without problems, but not deserialized. The original Type is not persistant and the result will be a Dictionary with KVP like: ("key1", {object}), ("key2", {object}) etc.

Is there any recommended workaround or solution to this problem?

commented

I'd recommend serializing the type information yourself alongside the actual data, and using Type.GetType() to get the target type back for deserialization. Unfortunately until #30 is resolved, you'll have to use reflection to pass this type into the Deserialize method.