使用带有方法的 asp.net webservice:
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<MyObject> GetList()
{
....return new List of MyObject{ x = .., y = .. , z = ..};
}
使用该服务的客户端使用 JQuery Ajax 调用运行良好
$.ajax({
type: "POST",
url: url,
data: data == null ? "{}" : data,
contentType: "application/json; charset=utf-8",
dataType: "json",
..... and so on ...
但是对于萤火虫,我注意到响应是:
{"d":[{"__type":"Common.MyObject","z":"2000","x":1500,"y":1000,"a":"0"},{"__type":"Common.MyObject","z":"2000","x":1455,"y":1199.57,"a":"1"}
...... and so on
]}
1) 问题是为什么我需要这个 ""__type":"Common.MyObject" ?
2) 我想删除它,所以响应会更小,我该怎么做?