又類的屬性生成json格式數據
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MV4項目學習.Controllers { public class HlhController : Controller { // GET: Hlh public JsonResult Index() { ViewData["app"] = "mlh1421"; ViewBag.name = "qwer"; //return View(); List<A> list = new List<A>(); list.Add(new A { Name = "mlh", Age = 12 }); return Json(list,JsonRequestBehavior.AllowGet); } public ActionResult Mlh() { return View("Show"); } } class A { public string Name { get;set; } public int Age { get; set; } } }