I'm currently in the process of developing a website that requires the display of a hierarchy, and I am faced with the restriction of constructing it using JSON.
Before diving into implementation, I find myself torn between two potential approaches for organizing the hierarchy, unsure of which one will offer the most efficient solution for my project.
Project Objective
The goal is to showcase a complete hierarchy on a webpage utilizing HTML5 BoilerPlate, with the hierarchy structure defined within the dico_tree
field. This data will need to be parsed using JavaScript to extract all the relevant information it holds.
Key Constraints
- Items can have either one parent or no parent at all (indicated by null).
- Items may have multiple children or none at all.
- The primary focus is to efficiently retrieve each unique item for rapid display on the webpage.
Potential Solutions Considered
Possibility 1
{
"dico_name" : "Dictionary",
"version" : "1",
"dico_tree" : [
{"ID" : 1,"parent" : null,"children" : [2]},
{"ID" : 2, "parent" : 1, "children": [3,4]},
{"ID" : 3, "parent" : 2, "children": null},
{"ID" : 4, "parent" : 2, "children": null},
{"ID" : 5,"parent" : null,"children" : [6]},
{"ID" : 6, "parent" : 5, "children": [7]},
{"ID" : 7, "parent" : 6, "children": null}],
"custom_translations_list" : [
{"TRANSLATION_ID" : 1, "CUSTOM_TRANSLATION_ID" : 12}
]
}
Possibility 2
{
"dico_name" : "Dictionary",
"version" : "1",
"dico_tree" : [
{"ID" : 1,"parent" : null,"children" : [
{
"ID" : 2, "parent" : 1, "childen": [
{
"ID" : 3, "parent" : 2, "children": null
},
{
"ID" : 4, "parent" : 2, "children": null
}
]
}
]},
{"ID" : 5,"parent" : null,"children" : [
{
"ID" : 6, "parent" : 5, "childen": [
{
"ID" : 7, "parent" : 6, "children": null
}
]
}
]}
],
"custom_translations_list" : [
{"TRANSLATION_ID" : 1, "CUSTOM_TRANSLATION_ID" : 12},
]
}
If further details are required, feel free to ask!
Thank you in advance for your time and assistance :).