0

I need to pass this list to my view: enter image description here

But in this format:

{
  "data": [
    {
      "FIRST_NAME": "Robert",
      "LAST_NAME": "Meczybula",
      "ID": 12421
       ...
     },
...
]}
1

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.