How to not serialize the __type property on JSON objects

Robert picture Robert · Mar 9, 2009 · Viewed 34k times · Source

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?

Answer

John Morrison picture John Morrison · Apr 22, 2009

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() { }