【发布时间】:2019-08-10 17:26:42
【问题描述】:
我想把一个html表的数据转换成json设置它的key。
var tbl = $('#table-availed-prod tr').map(function () {
return $(this).find('td').map(function () {
return $(this).html();
}).get();
}).get();
我得到的是这个
JSON:
或
Array(){
0: "Sophos"
1: "Complementary"
2: "Codey Ropen"
}
我需要的是这样的
JSON:
[{
Productname:"Sophos",
ProductTypename:"Software",
AssignedPerson:"Codey"
},
{
Productname:"Sophos",
ProductTypename:"Software",
AssignedPerson:"Codey"
},
{
Productname:"Sophos",
ProductTypename:"Software",
AssignedPerson:"Codey"
}]
【问题讨论】:
-
回答了类似的问题here
标签: jquery json html-table