I am trying to make a table which information is stored and updating(not appending) in a JSON file using JavaScript and HTML. The structure of my JSON data is as like as follows:
[{
"A": {
"name": "MAK",
"height": 170,
"place": "Canada"
},
"B": {
"name": "Jak",
"height": 164,
"place": "JAPAN"
},
"C": {
"name": "TAKO",
"height": 152,
"place": "ROMANIA"
},
"D": {
"name": "NARO",
"height": 192,
"place": "Portugal"
},
"E": {
"name": "Monako",
"height": 138,
"place": "Poland"
}
}]
Some details about the provided JSON information:
1/ With a random interval JSON file will be updated(not append).
2/ Key A.B.C ..... is not fixed. They could be increased and decreased.
3/Same also for their properties/sub-key(here name, height, place). New properties could come or remove.
4/ Besides, I cannot assure that all the time all properties will be present for all key. That means some place could be vacant.
I have added my required output which I want to see in the table. Hope it will depict the scenario in a better way. One flaw I am seeing here that the (0,0) coordinates of the table is vacant. Should I fill it/ left vacant with any string(probably in any other question it will be solved. If here then obviously awesome)?
Approach I have taken
1/ I am new in JavaScript so at first I want to try if I can iterate over the whole object and print all the content. You can see this fiddle. It can print all but the formation of the table does not meet the requirements.
2/ I have taken help from this answer.
Any solution regarding how to make the table will be highly appreciable.