【发布时间】:2017-01-11 12:18:05
【问题描述】:
嗯,我有以下 html 表:
<table id="people" border="1">
<thead>
<tr>
<th>Name</th>
<th>Places</th>
<th>Grade</th>
</tr>
</thead>
<tbody>
<tr>
<td>Oscar</td>
<td>New York</td>
<td>16.5</td>
</tr>
<tr>
<td>Antonio</td>
<td>
<p>New York</p>
<p>Chicago</p>
<p>Toronto</p>
</td>
<td>14</td>
</tr>
<tr>
<td>Jessica</td>
<td>New York</td>
<td>19</td>
</tr>
</tbody>
现在,当我使用 jquery tableToJson 函数时,我得到以下输出:
[
{"Name":"Oscar","Places":"New York","Grade":"16.5"},
{"Name":"Antonio","Places":"New York\n\t\t\tChicago\n\t\t\t\tToronto","Grade":"14"},
{"Name":"Jessica","Places":"New York","Grade":"19"}
]
现在看看 Antonio,创建的函数
{"Name":"Antonio","Places":"New York\n\t\tChicago\n\t\t\t\tToronto","Grade":"14"}
但不是
\n
我希望地点也显示为 JSON 数组,如下所示:
{"Name":"Antonio","Places":["New York","Chicago","Toronto"],"Grade":"14"}
我知道这里描述了一些选项 (https://github.com/lightswitch05/table-to-json),但我不知道该使用哪一个,或者如何使用它们,因为它没有真正记录,如何详细使用它们。
任何帮助将不胜感激:-)
【问题讨论】:
标签: javascript jquery html json html-table