【发布时间】:2011-03-14 16:33:42
【问题描述】:
我有一个 JSON 文件
{
"Scenario" : "ModelNameHere",
"id" : "1",
"description" : "Description of table model goes here",
"headers" : {
"Column 1 header" : {
"order" : 1,
"items" : {
"Row 1 Col 1 value" : {
"id" : 1,
"comment" : "Comment on Row 1 Col 1",
"order" : 1
},
"Row 2 Col 2 value" : {
"id" : 2,
"comment" : "Comment on Row 2 Col 2",
"order" : 2
}
}
},
"Column 2 header" : {
"order" : 2,
"items" : {
"Row 1 Col 2 value" : {
"id" : 3,
"comment" : "Comment on Row 1 Col 2",
"order" : 1
},
"Row 2 Col 2 value" : {
"id" : 4,
"comment" : "Comment on Row 2 Col 2",
"order" : 2
}
}
}
}
}
我想使用 jQuery 将 JSON 数据放入 HTML 表格中。
标题应该放在 TH td 项目中,标题中的项目应该是每个相关行的 TD 中的元素。
在 JS 或 jQuery 中是否有使用 JSON 数据填充表格的函数?
如何循环遍历 JSON 元素并将其与表格元素匹配?
谢谢。
【问题讨论】:
-
OP 有 31 年 :D 可能不是功课 :)
-
JSON 字符串无效,先在
JSLINT.com上检查这个
标签: javascript jquery json