我有以下类型的表,它是动态生成的。我希望将其转换为JSON
以下格式。我尝试了各种方法,但都是徒劳的。
有人可以帮我告知如何使用jQuery
.
注意:内表是使用for
循环动态生成的。
预期JSON
格式:
{"array" : [{"header1":"table1data1","header2":"table1data2","header3":"table1data3" },
{"header1":"table2data1","header2":"table2data2","header3":"table2data3" },
{"header1":"table3data1","header2":"table3data2","header3":"table3data3" }
]}
桌子:
<table id="Maintable">
<tr>
<td>
<table id="headertable">
<tr><th> header1</th></tr>
<tr><th> headr2</th></tr>
<tr><th> header3</th></tr>
</table>
</td>
<td>
<table class="innertable" id="innertable1">
<tr><td> table1data1</td></tr>
<tr><td> table1data2</td></tr>
<tr><td> table1data3</td></tr>
</table>
</td>
<td>
<table class="innertable" id="innertable2">
<tr><td> table2data1</td></tr>
<tr><td> table2data2</td></tr>
<tr><td> table2data3</td></tr>
</table>
</td>
...
<td>
<table class="innertable" id="innertable10">
<tr><td> table10data1</td></tr>
<tr><td> table10data2</td></tr>
<tr><td> table10data3</td></tr>
</table>
</td>
</tr>
</table>