Json.NET serialization pre and post calls

左心房为你撑大大i 提交于 2019-12-10 14:52:08

问题


I am using Json.NET to serialize an object graph. For each object that is serialized or deserialized, I want to call a method on that object before the serialization takes place. For e.g. all my objects implement an interface INotified with a method OnSerializing. I want OnSerializing to be called before the object is serialized.

Is there a way to achieve this without having to touch the Json.NET source code?


回答1:


The latest version of Json.NET supports serialization callbacks.



来源:https://stackoverflow.com/questions/1048311/json-net-serialization-pre-and-post-calls

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