相关疑难解决方法(0)

ASP.NET WebService使用XML标记包装我的JSON响应

我不确定我错过了什么,我错过了什么.

我正在构建一个ASP.NET 2.0(在.Net 3.5框架上)Web应用程序,我正在包含一个Web服务.请注意,这不是 MVC项目.我希望公开一个返回JSON字符串的方法; 格式化以提供jqGrid jQuery插件.

这是我在我的服务中实现的初步测试方法:感谢(Phil Haack的MVC指南)

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string getData()
{
    JavaScriptSerializer ser = new JavaScriptSerializer();

    var jsonData = new
    {
        total = 1, // we'll implement later 
        page = 1,
        records = 3, // implement later 
        rows = new[]{
          new {id = 1, cell = new[] {"1", "-7", "Is this a good question?", "yay"}},
          new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?", "yay"}},
          new …
Run Code Online (Sandbox Code Playgroud)

c# asp.net json web-services javascriptserializer

12
推荐指数
2
解决办法
4万
查看次数

标签 统计

asp.net ×1

c# ×1

javascriptserializer ×1

json ×1

web-services ×1