Prevent Shadowed Property From Getting Serialized

2019-07-16 01:40发布

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?

0条回答
登录 后发表回答