Skip to content

Instantly share code, notes, and snippets.

@hprobotic
Created November 23, 2018 06:17
Show Gist options
  • Select an option

  • Save hprobotic/a1edef65e7a969cb84815dad5fa1e44d to your computer and use it in GitHub Desktop.

Select an option

Save hprobotic/a1edef65e7a969cb84815dad5fa1e44d to your computer and use it in GitHub Desktop.
Givens a data.json file with structure bellow:
// data.json
[
{
"name": "Electronics",
"items": ["Phone", "Keyboards"]
},
{
"name": "Keyboards",
"items": ["Filco", "Razer"]
},
{
"name": "Cars",
"items": ["Hatchback", "MPV"]
},
{
"name": "Hatchback",
"items": ["Honda", "Ferrari"]
},
{
"name": "Phone",
"items": ["Apple", "Samsung"]
}
]
Goal is convert this table into structure that able to use to build mega menu structure bellow
```
|- Electronics
| |- Phone
| | |- Apple
| | |- Samsung
| |- Keyboards
| | |- Razer
| . | . |- Filco
|- Cars
| |- Hatchback
| | |- Honda
| | |- Ferrari
| |- MPV
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment