Prevent Shadowed Property From Getting Serialized

孤人 提交于 2019-12-11 04:25:53

问题


This is kind of piggybacking off of this question: ASP.NET: Shadowing Issues

I've discovered that the issue isn't actually that the property isn't getting serialized, it is, but that BOTH the shadowed and shadowing properties are getting serialized, and since the shadowed property is being serialized second, its value is the one that is available via JSON to my Javascript. My serialization code looks like this.

How can I ensure that my shadowed property does not get serialized, while still making that property available for serialization when that actual object (the base type object) needs to be serialized? Or at the VERY least, switch the order the properties are serialized so the correct one overrides the incorrect one?

来源:https://stackoverflow.com/questions/5570658/prevent-shadowed-property-from-getting-serialized

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