如何不序列化 JSON 对象上的 __type 属性 [英] How to not serialize the __type property on JSON objects

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

问题描述

我从 ScriptServiceWebMethod 返回的每个对象都被包装到一个 JSON 对象中,数据位于名为 d 的属性中.没关系.但我不希望将额外的 __type 属性提供给客户端,因为我使用 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 返回除 public 以外的任何内容,它不会序列化 __type:ClassName部分.

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.

你可能想声明你的默认构造函数 protected internal ClassName() { }

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

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

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