为什么 ASP.NET JSON Web 服务以“d"形式返回结果? [英] Why do ASP.NET JSON web services return the result in 'd'?
问题描述
我编写了一些使用 JSON 编码的 ASP.NET Web 服务,例如:
[WebInvoke()]【经营合同】public int SetInformation(int recordid, string data){返回 42;}
返回的JSON是:
{"d": 42}
为什么参数名为d
?我能控制吗?比如说,要e
?
作为参考,我终于能够挖掘出一些类似的问题:
这是一项安全"功能,可防止返回的 JSON 无法在 Eval 语句中直接执行 javascript.或者在这些方面非常相似的东西.
有关此主题的更多信息:http://encosia.com/a-break-change-between-versions-of-aspnet-ajax/ 看看标有Waiter, there's a .d in my msg汤的部分!
>
I wrote some ASP.NET web services that use JSON encoding, a la:
[WebInvoke()]
[OperationContract]
public int SetInformation(int recordid, string data)
{
return 42;
}
and the returned JSON is:
{"d": 42}
Why is the parameter named d
? Can I control that? Say, to e
?
For reference, a few similar questions I've finally been able to dig up:
- What does .d in JSON mean?
- How to change ASP.NET WebMethod's 'd' identifier in a JSON response, to a different name?
- Returning HTML from JSON webservice - what is the ".d"?
This is a "security" feature that prevents the JSON from being returned from being able to be directly executed javascript inside an Eval statement. Or something very similar along these lines.
More information on this topic: http://encosia.com/a-breaking-change-between-versions-of-aspnet-ajax/ take a look at the section labeled Waiter, there’s a .d in my msg soup!
这篇关于为什么 ASP.NET JSON Web 服务以“d"形式返回结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!