相关疑难解决方法(0)

如何将JSON对象转换为Custom C#对象?

有没有一种简单的方法来填充我的C#对象与通过AJAX传递的JSON对象?

//这是使用JSON.stringify从页面传递给C#WEBMETHOD的JSON对象

{
    "user": {
        "name": "asdf",
        "teamname": "b",
        "email": "c",
        "players": ["1", "2"]
    }
}
Run Code Online (Sandbox Code Playgroud)

// C#WebMetod接收JSON对象

[WebMethod]
public static void SaveTeam(Object user)
{

}
Run Code Online (Sandbox Code Playgroud)

// C#类,表示传入WebMethod的JSON Object的对象结构

public class User
{
    public string name { get; set; }
    public string teamname { get; set; }
    public string email { get; set; }
    public Array players { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net ajax json

233
推荐指数
8
解决办法
56万
查看次数

标签 统计

.net ×1

ajax ×1

asp.net ×1

c# ×1

json ×1