我在使用 json2html 时遇到问题 https://github.com/eisenbraun/columns图书馆 。是否可以将此 js 库与 Json 对象一起使用,如下所示。
var jsonobj = [{
"id": "31",
"Mesial": {
"disorder": "",
"other": ""
},
"Facial": {
"disorder": "DC-HP",
"other": ""
},
"Distal": {
"disorder": "",
"other": ""
},
"Lingual": {
"disorder": "",
"other": ""
},
"Occlusal": {
"disorder": "",
"other": ""
}
}, {
"id": "37",
"Mesial": {
"disorder": "",
"other": ""
},
"Facial": {
"disorder": "RE-AR",
"other": ""
},
"Distal": {
"disorder": "",
"other": ""
},
"Lingual": {
"disorder": "",
"other": ""
},
"Occlusal": {
"disorder": "",
"other": ""
}
}]
我使用过在线工具Convert JSON to HTML Table ,但不幸的是它的库不可用。
预期的表输出是
最佳答案
不,您的数据格式不正确。
您的格式需要尊重其数据格式:
[{"col1":"row1", "col2":"row1", "col3":"row1"}, {"col1":"row2", "col2":"row2", "col3":"row2"}]
每个对象都有一个 colX:rowY
格式。
所以你不能将对象作为行条目。
关于javascript - 使用 json2html 将 json 对象转换为 html 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53205962/