Arjuna Bandara
Arjuna Bandara

Reputation: 41

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 enter image description here

Upvotes: 0

Views: 495

Answers (1)

Alexandre Elshobokshy
Alexandre Elshobokshy

Reputation: 10922

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.

Upvotes: 2

Related Questions