Looking to generate a menu using JSON Array data
Here is the JSON Array:
[{
"page_id":"102608802958096849","title":"Submenu 1 1","page_order":1,"parent_id":"305280635460611248","layout":"header","page_url":"submenu-1-1.html"
},{
"page_id":"207782958260361106","title":"Submenu 2 1","page_order":1,"parent_id":"196241715470310788","layout":"header","page_url":"submenu-2-1.html"
},{
"page_id":"305280635460611248","title":"Submenu 1","page_order":1,"parent_id":"308333626876055885","layout":"header","page_url":"submenu-1.html"
},{
"page_id":"308333626876055885","title":"Demo","page_order":1,"parent_id":null,"layout":"header-slider","page_url":"index.html"
},{
"page_id":"357018431614169959","title":"Not Mega Menu","page_order":1,"parent_id":"756836287653398147","layout":"header","page_url":"not-mega-menu.html"
},{
"page_id":"363544895956322795","title":"Submenu 2 1 1","page_order":1,"parent_id":"207782958260361106","layout":"header","page_url":"submenu-2-1-1.html"
},{
"page_id":"130518632716609153","title":"New Page","page_order":2,"parent_id":"756836287653398147","layout":"header","page_url":"new-page.html"
},{
"page_id":"196241715470310788","title":"Submenu 2","page_order":2,"parent_id":"308333626876055885","layout":"header","page_url":"submenu-2.html"
},{
"page_id":"520778073299851538","title":"Submenu 2 2","page_order":2,"parent_id":"196241715470310788","layout":"header","page_url":"submenu-2-2.html"
},{
"page_id":"756836287653398147","title":"Phoenix","page_order":2,"parent_id":null,"layout":"header","page_url":"phoenix.html"
},{
"page_id":"951287960823231869","title":"Submenu 2 1 2","page_order":2,"parent_id":"207782958260361106","layout":"header","page_url":"submenu-2-1-2.html"
}]
The desired menu structure should resemble the following:
HTML:
<ul>
<li>
<a>Demo</a>
<div>
<ul>
<li>
<a>Submenu 1</a>
<div>
<ul><li><a>Submenu 1 1</a></li></ul>
</div>
</li>
<li>
<a>Submenu 2</a>
<div>
<ul>
<li>
<a>Submenu 2 1</a>
<div>
<ul>
<li>
<a>Submenu 2 1 1</a>
</li>
<li>
<a>Submenu 2 1 2</a>
</li>
</ul>
</div>
</li>
<li>
<a>Submenu 2 2</a>
</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
<li>
<a>Phoenix</a>
<div>
<ul>
<li><a>New Page</a></li>
<li><a>Not Mega Menu</a></li>
</ul>
</div>
</li>
Please note:
For example: "page_id":"102608802958096849","title":"Submenu 1 1","page_order":1,"parent_id":"305280635460611248","layout":"header","page_url":"submenu-1-1.html"
page_id = 102608802958096849 (defines the menu id)
title = Submenu 1 1 (the title of the menu item)
page_order = 1 (represents the position of the menu item)
Any suggestions on how to construct the above menu from the JSON array provided? Thank you in advance