I'm trying to come up with the best way to generate a table from the below JSON object:
mytable=[ {div:{ nested:[ {table:{ nested:[ {thead:{ nested:[ {tr:{ nested:[ {th:{}}, {th:{}}, {th:{}} ]}} ] }}, {tbody:{}} ]}} ]}} ]; The end result would generate the HTML elements and be structured like so:
<div> <table> <thead> <tr> <th></th> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody></tbody> </table> </div> My logic is to check if the the object has the property nested if so generate the element and continue to loop, however I can't figure out how to do the bind the child elements back to the parents at the same time.
JSONis not valid. You have a problem with your nestedth. Plus, what have you tried?