How to serialize ExpandoObject using ServiceStack JsonSerializer?

落爺英雄遲暮 提交于 2019-12-05 06:35:06

There aren't any hooks available in ServiceStack's JsonSerializer that you can plug into to change this behaviour but I'm be more than happy to take a pull request that does it ;)

The classes you will need to change are:

  • JsWriter.cs (Line 223) - insert code to detect an expando object and return a delegate that writes the expando object how you want it.
  • JsReader (Line 42) - insert code to detect an expando object and return a delegate to read the contents of a string and deserialize it back into an expando

I imagine the code for dealing with an expando object is similar to a dictionary so you should be able to use the Dictionary implementation classes to guide you (i.e. WriteDictionary.cs and DeserializeDictionary.cs)

Feel free to use the ServiceStack forum if you have any more questions/issues on this: https://groups.google.com/forum/#!forum/servicestack

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