++ Model public class Product{ public int ProductId { get; set; } public string ProductName { get; set; } public DataTable dt = new DataTable(); public Category Category = new Category(); } ++Controller public JsonResult Index(){ Product dto = new Product(); dto.ProductId = 1; dto.ProductName = "Coca Cola"; return Json(dto, JsonRequestBehavior.AllowGet); }
How to specific Json object, I mean need only ProductId, ProductName and other no need to Json object.
++Want { "ProductId": 1, "ProductName": "Coca Cola" }