如何不序列化的JSON对象的__t​​ype财产 [英] How to not serialize the __type property on JSON objects

查看:109
本文介绍了如何不序列化的JSON对象的__t​​ype财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从返回的每个对象的WebMethod ScriptService 包装到与一个数据的JSON对象物业命名为 D 。没关系。但我不希望其他 __类型属性被提供给客户端,因为我做的手工加工与jQuery。

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.

这可能吗?

推荐答案

那么它是一个漫长的时间,因为你问。我发现,如果我让我的类的默认构造函数是我的webmethod返回以外的公众也不会序列化__type:类名部分

Well it's been a long time since you asked. 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(){}

这篇关于如何不序列化的JSON对象的__t​​ype财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆