JSON deserialization to inherited types

2019-03-18 05:18发布

I have a data table in my database where I store various settings. Since they are of any type (even complex object graphs) I decided to store their values as serialized JSON strings.

Let's say that I serialized a List<ItemBase>. Serialized string looks just fine. But the problem is that list items are of various types that are inherited from ItemBase (which may as well be abstract for what I care).

Question

Which (de)serialization class/library should I use so my JSON strings will be correctly deserialized to correct object instances.

1条回答
Animai°情兽
2楼-- · 2019-03-18 05:46

json.net has the ability to preserve references

And it supports storing the type

查看更多
登录 后发表回答