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

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

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

[
    {"id":"1","name":"User"},
    {"id":"2","name":"Group"},
    {"id":"3","name":"Permission"}
]

 

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

Deserialize your Json and cast it directly to datatable.

DataTable dt = (DataTable)JsonConvert.DeserializeObject(jsonText, (typeof(DataTable)));

2020-02-08