your object isn't valid JS. You can't have keys that aren't assigned.
So for example this:
Code
folderB: {
fileA,
fileB
},
Throws an error. Did you mean for this to be an array of either filenames(single string) or folder (folder name as the key, the values are an array of files or folders)?
I would usually write your object as an array like the following, except in any real world environment, you would usually get back an array of objects instead of a mixed array.
Code
const graphArray = [
{
'name': 'folderA',
children: [
{
name: 'folderAB',
children: [
'fileAA',
'fileAB'
]
},
'fileAC',
'fileAD',
{
name: 'folderAC',
children: [
'fileAE',
{
name: 'folderAF',
children: []
}
]
}
]
}
];
Otherwise, this is what your original object looks like but made to be valid:
Code
folderA: {
folderAB: {
fileAA: 'file.aa',
fileAB: 'file.ab'
},
fileAC: 'file.ac',
fileAD: 'file.ad',
folderAC: {
fileAE: 'file.ae',
folderAF: {}
}
},
This post was edited by frixionburne on Nov 27 2019 03:37pm