I have a Javascript array of the form:
var array = [Company_stock_content\\LightRhythmVisuals\\LRV_HD", "Big Media Test\\ArtificiallyAwake\\AA_HD", "Big Media Test\\Company\\TestCards_3840x2160\\TestCards_1920x1080",...]
I need to construct a JSON object of the form:
[
{
"data" : "parent",
"children" : [
{
"data" : "child1",
"children" : [ ]
}
]
}
]
so for each top level node in the array it can have multiple children that all have children. for example if we take the array snipper provided, the corresponding JSON object would look as such
[{
"data": "Company_stock_content",
"children": [{
"data": "LightRhythmVisuals",
"children": [{
"data": "LRV_HD"
}]
}]
}, {
"data": "Big Media Test",
"children": [{
"data": "ArtificiallyAwake",
"children": [{
"data": "AA_HD"
}]
}, {
"data": "Company",
"children": [{
"data": "TestCards_3840x2160"
}]
}]
}]
How can I this structure from the given data bearing in mind the original array can have tens of thousands of entries?