Convert Datatable to Json C#

708
convert datatable to json c#

Convert Json Response to Datatable C#

Json format is a lightweight data-interchange format for storing and exchanging data. It is easy for machines to parse and generate. I recently needed to serialize a datatable to JSON. So in this c# tutorial we will learn about how to convert datatable to json c# asp.net web application.

The following example demonstrates two different ways to convert datatable to json in asp.net c#. First you can write customized method and secondly you can use serialization () in asp.net web application. Find the source code below:-

Download Source Code

Also there is an easier method than the other answers here, which require first deserializing into a c# class, and then turning it into a datatable. It is possible to go directly to a datatable, with JSON.NET and code like this:

Did you find this post useful? I hope you liked this article. Please share with me your valuable suggestions and feedback.

LEAVE A REPLY

Please enter your comment!
Please enter your name here