For this class
class Customer {
public string FirstName {get; set;}
public string LastName {get; set;}
}
I have collection
List<Customer> customers
When returning to browser client
return new JsonResult(new
{
data = customers
});
The client get
{"data":[{"firstName":"Johny","lastName":"Johnson"}]}
Is there some way to get
{"data":[{"Johny","Johnson"}]}
without doing foreach like
var output = new List<string[]>();
foreach (var r in customers)
{
output.Add(new string[] {
r.FirstName,
r.LastName
});
}
?
jquery datatable libraryand by default this is presumed format, but because my table contains a lot of columns i want to avoid manually mapping object to an array.foreach. Thedatatable pluginprobably map the array to the table based on value position. For example value ofcustomer[3][2]will be in 3rd row and 2nd column.