In a few posts here and also on other forums I have found this code quoted for turning a Json object into a DataTable:
DataTable dt = (DataTable)JsonConvert.DeserializeObject(json, (typeof(DataTable)));
I can't get this to work. It always throws a JsonSerializationException. Am I missing something?
This is simple example to show error:
JObject query = new JObject();
JObject results = new JObject();
results.Add("Name", "Blue Umbrella");
results.Add("Price", 100);
query.Add("results", results);
DataTable dt = (DataTable)JsonConvert.DeserializeObject(query.ToString(), (typeof(DataTable)));
What did I do wrong?
query.ToString()and compare that with the other examples that you've seen.