简体   繁体   English

使用json2html将json对象转换为html表

[英]json object to html table conversion using json2html

I am having a problem when using json2html https://github.com/eisenbraun/columns library . 使用json2html https://github.com/eisenbraun/columns库时出现问题。 Is it possible to use this js library with Json object as below. 是否可以将这个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": ""
  }
}]  

I have used online tool Convert JSON to HTML Table , but unfortunately it's library is not available. 我使用了在线工具“ 将JSON转换为HTML表” ,但不幸的是它的库不可用。

expected table output is 预期表输出为

snap 在此处输入图片说明

No, your data format is incorrect. 不,您的数据格式不正确。

Your format need to respect their data format of : 您的格式需要遵循以下数据格式:

[{"col1":"row1", "col2":"row1", "col3":"row1"}, {"col1":"row2", "col2":"row2", "col3":"row2"}]

Having for each object a colX:rowY format. 每个对象都有colX:rowY格式。

So you can't have an object as a row entry. 因此,您不能将对象作为行条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM