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)
    – Bun
    CommentedMay 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); 
0
    0

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

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.