BinaryPack icon indicating copy to clipboard operation
BinaryPack copied to clipboard

Deserializing Dictionary<string, object>

Open lm-adruschel opened this issue 4 years ago • 1 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?

lm-adruschel avatar Jun 09 '20 11:06 lm-adruschel

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.

Arlodotexe avatar Mar 04 '22 04:03 Arlodotexe