super-user super-user - 3 months ago 32x
JSON Question

JSON to C# a Dynamic List<object> or DataTable

Short version: How can I deserialize a JSON string into a C# list or DataTable without having a defined class to deserialize to?

More explanation: My controller expects a json string which is an array of objects but the properties of the object is unknown. I need to deserialize it into a list and loop through its contents for saving. Sample json strings:





dynamic jsonObject = System.Web.Helpers.Json.Decode(jsonText);