How to convert datatable to json string using json.net?

string json = JsonConvert.SerializeObject(table, Formatting.Indented);

Edit: You don’t need indented formatting, of course, but it makes it nice and readable.

Leave a Comment