生成Json友好结果的最佳方法(.NET MVC)

2 asp.net-mvc json

我现在ListItem()用于Json格式的结果,但生成的Json文本有一个额外的属性"selected = false",我知道这用于下拉列表,但我希望我的应用程序运行得更快,所以我不想要这个属性.你知道其他任何方法来获得类似的结果吗?

这是我的代码:

List<ListItem> list = new List<ListItem>() {
    new ListItem() { Text = "Email", Value = "Pls enter your email" },
    new ListItem() { Text = "NameFull", Value = "Pls enter your full name" },
    new ListItem() { Text = "Sex", Value = "Pls choose your sex" }
};
Run Code Online (Sandbox Code Playgroud)

Edu*_*añó 6

如果您使用的是ASP.NET MVC Beta,则可以使用Json函数和匿名类型将任何对象序列化为JSON.

public JsonResult GetData() {
    var data = new { Text = "Email", Value = "Pls enter your email" }; 
    return Json(data);
}
Run Code Online (Sandbox Code Playgroud)