With the usage of Javascript, I am dealing with an array structured as follows:
[{"id":171,
"children":
[{"id":172},
{"id":170},
{"id":173}]},
{"id":174},
{"id":175}]
This array is created from a nestable jQuery list.
Now, I have the requirement to push this array into another one that has the structure of id, top_menu, and submenu entries.
I have attempted around 15 different loops in order to identify commas and determine whether it's a top_menu or sub_menu item based on what comes before the comma. However, all my attempts have failed at some level or another.
Is there a specific function that could simplify this process?
Currently, I am using str.split(',') to locate commas and then applying search and substr methods to establish the menu hierarchy. Any assistance on this matter would be greatly valued.