How to not serialize the __type property on JSON objects

asmx, asp.net, c#, javascriptserializer, json

Solution

I found that if I make the default constructor of my class that my webmethod returns anything other than public it will not serialize the `__type:ClassName` portion.

You may want to declare your default constructor `protected internal ClassName() { }`

Problem

Every object I return from a `WebMethod` of a `ScriptService` is wrapped into a JSON object with the data in a property named `d`. That's ok. But I don't want the additional `__type` property to be served to the client, since I do manual processing with jQuery. Is it possible?

Original source

Related problems