4

Following is my javascript array which I am passing from the server.

string request = @"[[1,""Name"",""Sam"",""20""],1,""Name"",""Ram"",""20""]]";

I want to convert it into a List of C# object.

public class UpdateData
    {
        public int RowID { get; set; }

        public string ColumnName { get; set; }

        public string OldValue { get; set; }

        public string NewValue { get; set; }

    }

Is there a way to do that?

1
  • 3
    The easy way would be to use JSON... There are plenty of good librairies to help with serializing/deserializing (check Newtonsoft.Json) Commented May 23, 2014 at 17:48

2 Answers 2

8

First get a List of Lists and then loop over it to form your List of UpdateData (using Json.Net)

 var obj = JsonConvert.DeserializeObject <List<List<object>>>(request);
Sign up to request clarification or add additional context in comments.

Comments

0

You'll want a Json parser. Use Nuget to add one to your project: Install-Package Newtonsoft.Json

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.