-1

Hi We are calling a webapi from c#. Getting json data. How to convert Json string to Datatable. I have read many posts suggesting to use a class, but my json string has 1024 columns...

How to convert Json string to Datatable without using a class

JsonConvert.DeserializeObject<DataSet>(json) 

This didn't work

Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215
Mallikharjun
  • 9
  • 1
  • 4

2 Answers2

0

You have to deserialize it into DataTable, not Dataset :

var table = JsonConvert.DeserializeObject<DataTable>(json);

greyxit
  • 693
  • 3
  • 13
-1

In your case you want to convert it into data table.

var resultDataTableHere = JsonConvert.DeserializeObject<DataTable>(YourJsonResultHere);
Selaka Nanayakkara
  • 3,296
  • 1
  • 22
  • 42