Click or drag to resize
Json.NETDeserialize a DataSet
 

This sample deserializes JSON to a DataSet.

Sample
Usage
 1string json = @"{
 2  'Table1': [
 3    {
 4      'id': 0,
 5      'item': 'item 0'
 6    },
 7    {
 8      'id': 1,
 9      'item': 'item 1'
10    }
11  ]
12}";
13
14DataSet dataSet = JsonConvert.DeserializeObject<DataSet>(json);
15
16DataTable dataTable = dataSet.Tables["Table1"];
17
18Console.WriteLine(dataTable.Rows.Count);
19// 2
20
21foreach (DataRow row in dataTable.Rows)
22{
23    Console.WriteLine(row["id"] + " - " + row["item"]);
24}
25// 0 - item 0
26// 1 - item 1