Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a JavaScript array into a C# List

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?

like image 397
Muthukumar Avatar asked Oct 28 '25 18:10

Muthukumar


1 Answers

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);
like image 154
L.B Avatar answered Oct 31 '25 08:10

L.B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!