Very likely a rather trivial question, but I simply couldn’t find an appropriate answer. I want to return a “JsonResult” without the actual result having ANY property names whatsoever. Here is a little example of what I want to achieve:
["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"]]
Yes, some very ordinary source code already exists, but I doubt this is of any relevance. However, here it is:
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);
}
Here you go:
UPDATE:
and for those that are impatient to test without an actual repository:
returns:
which is exactly the expected JSON.