我试图让我的控制器返回一个命名的 JSON 数组。它当前返回格式如下的 JSON:
[{"Title":"Star Wars: A New Hope","Year":1977},{"Title":"Star Wars: The Empire Strikes Back","Year":1980},{"Title":"Star Wars: Return of the Jedi","Year":1983}]
但我想要这样
movies:[{"Title":"Star Wars: A New Hope","Year":1977},{"Title":"Star Wars: The Empire Strikes Back","Year":1980},{"Title":"Star Wars: Return of the Jedi","Year":1983}]
这是我的控制器方法:
public JsonResult GetMovies()
{
var model = _movies;
return Json(model, JsonRequestBehavior.AllowGet);
}
有任何想法吗?