<table id="table" style="width: 100%;" cellpadding="0" cellspacing="0"> <thead> <tr> <td>颜色</td> <td>套餐</td> <td>版本</td> <td>价格</td> <td>数量</td> <td>编号</td> <td>条形码</td> </tr> </thead> <tbody> <tr> <td rowspan="4">红色</td> <td rowspan="2">套餐四</td> <td>港货</td> <td>99.9</td> <td>100</td> <td>123456789</td> <td>987654321</td> </tr> <tr> <td>日货</td> <td>99.9</td> <td>100</td> <td>123456789</td> <td>987654321</td> </tr> <tr> <td rowspan="2">套餐八</td> <td>港货</td> <td>99.9</td> <td>100</td> <td>123456789</td> <td>987654321</td> </tr> <tr> <td>日货</td> <td>99.9</td> <td>100</td> <td>123456789</td> <td>987654321</td> </tr> <tr> <td rowspan="4">蓝色</td> <td rowspan="2">套餐四</td> <td>港货</td> <td>99.9</td> <td>100</td> <td>123456789</td> <td>987654321</td> </tr> <tr> <td>日货</td> <td>99.9</td> <td>100</td> <td>123456789</td> <td>987654321</td> </tr> <tr> <td rowspan="2">套餐八</td> <td>港货</td> <td>99.9</td> <td>100</td> <td>123456789</td> <td>987654321</td> </tr> <tr> <td>日货</td> <td>99.9</td> <td>100</td> <td>123456789</td> <td>987654321</td> </tr> </tbody> </table>
我这是一个html的表格,行列都是不确定的,上面数据只是一种例子。
用js怎么把此数据表格转化成一个json数据,并且也可以把json数据转化成这中表格,是双向的。应该如何实现呢。
json的格式我已经定义好了,不过中间的过程转化确实感觉不好实现,有哪位大神能帮忙解决一下啊。求一个读写转化的方法。
下面是json格式:
var _77 = { "Category": [ "机身颜色", "套餐类型", "机身内存", "版本型号" ], "Series": [ { "红": [ { "套餐四": [ { "1.5GB": [ { "港澳台": [ 99.9, 100, "4561545613", "123456789" ], "日本": [ 88.8, 222, "9876453142", "654789313" ] } ], "64GB以上": [ { "港澳台": [ 99.9, 100, "4561545613", "123456789" ], "日本": [ 88.8, 222, "9876453142", "654789313" ] } ] } ] }, { "套餐八": [ { "1.5GB": [ { "港澳台": [ 99.9, 100, "4561545613", "123456789" ], "日本": [ 88.8, 222, "9876453142", "654789313" ] } ], "64GB以上": [ { "港澳台": [ 99.9, 100, "4561545613", "123456789" ], "日本": [ 88.8, 222, "9876453142", "654789313" ] } ] } ] } ] }, { "蓝": [ { "套餐四": [ { "1.5GB": [ { "港澳台": [ 99.9, 100, "4561545613", "123456789" ], "日本": [ 88.8, 222, "9876453142", "654789313" ] } ], "64GB以上": [ { "港澳台": [ 99.9, 100, "4561545613", "123456789" ], "日本": [ 88.8, 222, "9876453142", "654789313" ] } ] } ] }, { "套餐八": [ { "1.5GB": [ { "港澳台": [ 99.9, 100, "4561545613", "123456789" ], "日本": [ 88.8, 222, "9876453142", "654789313" ] } ], "64GB以上": [ { "港澳台": [ 99.9, 100, "4561545613", "123456789" ], "日本": [ 88.8, 222, "9876453142", "654789313" ] } ] } ] } ] } ] }
您好我想问一下您这个问题怎么解决的?比较着急,请速回复谢谢