I am trying to construct the following JSON within JQuery with a editable table but I don't know where should I begin, since my heading, the number of boarding zone(columns) and the number of route serial(rows) changes all the time, therefore I have to manually pull out the data and construct the JSON per row. Thank you in advances for any comment and reply.
{ "name": txtRouteName.val(),
"serial": [
{ "rsn": "X100", "boardingzone": [
{ "name": "Foo", "time": "8:00" },
{ "name": "Bar", "time": "8:15"}
] },
{ "rsn": "X101", "boardingzone": [
{ "name": "Foo", "time": "9:00" },
{ "name": "Bar", "time": "9:15"}
] }
]
};
where the table are displayed as follow:
<table id="table1">
<tr>
<td>RSN</td>
<td>Foo</td>
<td>Bar</td>
</tr>
<tr>
<td>X100</td>
<td>8:00</td>
<td>8:15</td>
</tr>
<tr>
<td>X101</td>
<td>9:00</td>
<td>9:15</td>
</tr>
</table>