title: Nested Json String to DataTable
body: <p>I Need to convert the following Json string to DataTable.</p>
  
  <pre><code>{  
     "pnr":"1234567890",
     "train_num":"12311",
     "train_name":"HWH DLIKLK MAI",
     "doj":"23-12-2013",
     "from_station":
     {  
        "code":"DLI",
        "name":"Delhi"
     },
     "to_station":
     {  
        "code":"KLK",
        "name":"Kalka"
     }
  }
  </code></pre>
  
  <p>In DataTable I need to Display </p>
  
  <pre><code>train_num
  train_name
  doj
  from_station(name only)
  to_station(name only)
  </code></pre>
  
  <p>What i have till now is,</p>
  
  <pre><code>public class Train
  {
  public string train_num { get; set; }
  public string train_name { get; set; }
  public string doj { get; set; }
  public from_station from_station { get; set; }
  public to_station to_station { get; set; }
  }
  
  public class from_station
  {
  public string code { get; set; }
  public string name { get; set; }
  }
  public class to_station
  {
  public string code { get; set; }
  public string name { get; set; }
  }
  
  public static DataTable ToDataTable(Train data)
  {
      PropertyDescriptorCollection props =
      TypeDescriptor.GetProperties(typeof(Train));
      DataTable table = new DataTable();
  
      for (int i = 0; i &lt; props.Count; i++)
      {
          PropertyDescriptor prop = props[i];
          table.Columns.Add(prop.Name, prop.PropertyType);
      }
      object[] values = new object[props.Count];
  
          for (int i = 0; i &lt; values.Length; i++)
          {
              values[i] = props[i].GetValue(data);
          }
          table.Rows.Add(values);
      return table;
  }
  
  var data = JsonConvert.DeserializeObject&lt;Train&gt;(JsonString);
      dt = ToDataTable(data);
      ui_grdVw_EmployeeDetail1.DataSource = dt;
      ui_grdVw_EmployeeDetail1.DataBind();
  </code></pre>
  
  <p>I am getting only three columns in datatable </p>
  
  <pre><code>train_num
  train_name
  doj
  </code></pre>