Returning multiple objects with a JSON result

asp.net-mvc, c#, jquery, json

Solution

Just return some enumerable if you want an array:

return Json ( Enumerable.Range(0, 10).Select(i => new { Name = "N" + i, Price = i });

Problem

i am wondering if it is possible to return multiple objects with a JSON result in MVC. At the moment i have no problem to return a single object. ``` public ActionResult AddToBasket(int quantity, int productdetailid) { // more code here return Json ( new { Name = p.Product.Name, Price = p.Price}); } ``` This returns a single anonymous object in my ajax call.What i wanna do is return multiple Names and Prices to fill a table in my view. So basicly i wanna update(renew) the cookie every time the user adds a item to his basket and update the basket which is a html table. Thanks in advance.

Original source