I need to pass this list to my view:
But in this format:
{
"data": [
{
"FIRST_NAME": "Robert",
"LAST_NAME": "Meczybula",
"ID": 12421
...
},
...
]}
I need to pass this list to my view:
But in this format:
{
"data": [
{
"FIRST_NAME": "Robert",
"LAST_NAME": "Meczybula",
"ID": 12421
...
},
...
]}
Basically you want to transform your list to the desired data contract. Linq is good for this:
var transform = new
{
data = data.Select(x =>
new {
x.FIRST_NAME,
x.LAST_NAME,
...
}),
...
};
Then just serialize and return the transform object.