title: Get Table data in json format
body: <p>Hello everyone I'm trying to get table data in json format here is my table</p>
  
  <pre><code>   &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;srno&lt;/th&gt;
        &lt;th&gt;name&lt;/th&gt;
        &lt;th&gt;email&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Jhon One&lt;/td&gt;
        &lt;td&gt;Doe one&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;Jhon two&lt;/td&gt;
        &lt;td&gt;Doe Two&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;button&gt;
    convert
  &lt;/button&gt;
  </code></pre>
  
  <p>the result which i am getting is this</p>
  
  <pre><code>{
      "0": {
          "1",
          "Jhon One",
          "Doe one"
      }
      ,
      "1": {
          "2",
          "Jhon two",
          "Doe Two"
      }
  }
  </code></pre>
  
  <p>using the below javascript</p>
  
  <pre><code>$("button").click(function() {
    var json = html2json();
    alert(json);
  });
  
  function html2json() {
    var json = '{';
    var otArr = [];
    // var i = 1;
    var tbl2 = $('table tbody tr').each(function(e) {
      x = $(this).children();
      var itArr = [];
      x.each(function() {
        itArr.push('"' + $(this).text() + '"');
      });
      otArr.push('"' + e + '": {' + itArr.join(',') + '}');
    })
    json += otArr.join(",") + '}'
  
    return json;
  }
  </code></pre>
  
  <p>but i want to add key to every value and the number should start from one and not zero.</p>
  
  <p>i have a set of desire result and it should look like this
  any help is appreciated </p>
  
  <pre><code>  {
          "1": {
             no: "1",
             name:"Jhon One",
             lastname "Doe one"
          }
          ,
           "2": {
             no: "1",
             name:"Jhon two",
             lastname "Doe two"
          }
  
      }
  </code></pre>
  
  <p>here is the fiddel link which i have tried</p>
  
  <p><a href="https://jsfiddle.net/k228n2bn/" rel="nofollow noreferrer">https://jsfiddle.net/k228n2bn/</a></p>