javascript – HTML表格的JSON格式

我正在使用lightswitch的脚本将
HTML表格编码为
JSON字符串(
https://github.com/lightswitch05/table-to-json).问题是,当我警告结果字符串(使用JSON.stringify(data))时,JSON记录从第13列开始,然后继续直到结束,然后继续从第1列到第12列.我不明白为什么,这个脚本似乎在每张桌子上都能正常工作,但不是我的:

<div contenteditable>

<table id="input">
<tr id="start">
  <th contenteditable="false">00</th>
  <th contenteditable="false">00</th>
  <th contenteditable="false">00</th>
  <th contenteditable="false">01</th>
  <th contenteditable="false">02</th>
  <th contenteditable="false">03</th>
  <th contenteditable="false">04</th>
  <th contenteditable="false">05</th>
  <th contenteditable="false">06</th>
  <th contenteditable="false">07</th>
  <th contenteditable="false">08</th>
  <th contenteditable="false">09</th>
  <th contenteditable="false">10</th>
  <th contenteditable="false">11</th>
  <th contenteditable="false">12</th>
  <th contenteditable="false">13</th>
  <th contenteditable="false">14</th>
  <th contenteditable="false">15</th>
  <th contenteditable="false">16</th>
  <th contenteditable="false">17</th>
  <th contenteditable="false">18</th>
  <th contenteditable="false">19</th>
  <th contenteditable="false">20</th>
  <th contenteditable="false">21</th>
  <th contenteditable="false">22</th>
  <th contenteditable="false">23</th>
  <th contenteditable="false">24</th>
  <th contenteditable="false">25</th>
  <th contenteditable="false">26</th>
  <th contenteditable="false">27</th>
  <th contenteditable="false">28</th>
  <th contenteditable="false">29</th>
  <th contenteditable="false">30</th>
  <th contenteditable="false">31</th>
  <th contenteditable="false">32</th>
  <th contenteditable="false">33</th>
  <th contenteditable="false">34</th>
  <th contenteditable="false">35</th>
  <th contenteditable="false">36</th>
  <th contenteditable="false">37</th>
  <th contenteditable="false">38</th>
  <th contenteditable="false">39</th>
  <th contenteditable="false">40</th>
  <th contenteditable="false">41</th>
  <th contenteditable="false">42</th>
  <th contenteditable="false">43</th>
  <th contenteditable="false">44</th>
  <th contenteditable="false">45</th>
  <th contenteditable="false">46</th>
  <th contenteditable="false">47</th>
  <th contenteditable="false">48</th>
  <th contenteditable="false">49</th>
  <th contenteditable="false">50</th>
  <th contenteditable="false">51</th>
  <th contenteditable="false">52</th>
</tr>


<tr>
  <td contenteditable="false">2nd row</td>
  <td contenteditable="false">false data</td>
  <td>2</td>
  <td></td>
  <td></td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>7</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>6</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td>8</td>
  <td></td>
  <td>8</td>
  <td></td>
  <td>1</td>
  <td></td>
  <td></td>
  <td></td>
  <td>8</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
 </tr>

等等所有其他行.
我需要以JSON格式保存此表,以便将JSON存储在数据库中并保存修改后的数据.那么,如何从JSON返回表格?

最佳答案 您正在使用
JSON.stringify,因此您需要考虑以下因素:

Properties of non-array objects are not guaranteed to be stringified
in any particular order. Do not rely on ordering of properties within
the same object within the stringification.

但这真的是一个问题吗?将数据发送到服务器后,无论如何都可以订购它.

点赞