title: Datatable to json - c#
body: <p>I have a data table like below</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Subject</th>
  <th>Question</th>
  <th>Qtype</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>English</td>
  <td>xxxxxxx</td>
  <td>Subjective</td>
  </tr>
  <tr>
  <td>English</td>
  <td>yyyyyyy</td>
  <td>Subjective</td>
  </tr>
  <tr>
  <td>English</td>
  <td>zzzzzzz</td>
  <td>Objective</td>
  </tr>
  <tr>
  <td>English</td>
  <td>sasasas</td>
  <td>Objective</td>
  </tr>
  <tr>
  <td>English</td>
  <td>cvcvcvv</td>
  <td>Subjective</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Question column will contain the question in text format.</p>
  <p>Json should be</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;Subject&quot;:&quot;English&quot;,
      &quot;xxxxxxx&quot;:&quot;Subjective&quot;,
      &quot;yyyyyyy&quot;:&quot;Subjective&quot;,
      &quot;zzzzzzz&quot;:&quot;Objective&quot;,
      &quot;sasasas&quot;:&quot;Objective&quot;,
      &quot;cvcvcvv&quot;:&quot;Subjective&quot;
  }
  </code></pre>
  <p>I have tried like below. But this will not return above output.</p>
  <pre class="lang-cs prettyprint-override"><code>var list = new List&lt;string[]&gt;();
  foreach (DataRow row in dt_questions.Rows)
  {
      string Subject   = row[&quot;Subject&quot;].ToString();
      string Question= row[&quot;Question&quot;].ToString();
      string Qtype= row[&quot;Qtype&quot;].ToString();
      list.Add(new string[] { Subject, Question, Qtype});
  }
  var jsonSerialiser = new JavaScriptSerializer();
  var json = jsonSerialiser.Serialize(list);
  </code></pre>