JSON deserialization to inherited types

偶尔善良 提交于 2019-12-20 18:06:39

问题


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:


json.net has the ability to preserve references

And it supports storing the type



来源:https://stackoverflow.com/questions/4272972/json-deserialization-to-inherited-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!