-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
  • 165,109
  • 17
  • 150
  • 199
Mallikharjun
  • 9
  • 1
  • 4

2 Answers2

0

You have to deserialize it into DataTable, not Dataset :

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

greyxit
  • 623
  • 3
  • 12
-1

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

var resultDataTableHere = JsonConvert.DeserializeObject<DataTable>(YourJsonResultHere);
Selaka Nanayakkara
  • 2,258
  • 16
  • 34