简体   繁体   中英

json object to html table conversion using json2html

I am having a problem when using json2html https://github.com/eisenbraun/columns library . Is it possible to use this js library with Json object as below.

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.

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.

So you can't have an object as a row entry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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