很可能是一个相当微不足道的问题,但我根本找不到合适的答案。我想返回一个“JsonResult”,而实际结果没有任何属性名称。这是我想要实现的一个小例子:
["xbox",
["Xbox 360", "Xbox cheats", "Xbox 360 games"],
["The official Xbox website from Microsoft", "Codes and walkthroughs", "Games and accessories"],
["http://www.xbox.com","http://www.example.com/xboxcheatcodes.aspx", "http://www.example.com/games"]]
是的,一些非常普通的源代码已经存在,但我怀疑这是否相关。但是,这里是:
public JsonResult OpensearchJson(string search)
{
/* returns some domain specific IEnumerable<> of a certain class */
var entites = DoSomeSearching(search);
var names = entities.Select(m => new { m.Name });
var description = entities.Select(m => new { m.Description });
var urls = entities.Select(m => new { m.Url });
var entitiesJson = new { search, names, description, urls };
return Json(entitiesJson, JsonRequestBehavior.AllowGet);
}