delferns2001
❔ Creating a hierarchy algorithm
I have an image model, which consists of
public Guid Id { get; set; }
public string Name { get; set; }
public List<string> VirtualDir { get; set; }
virtual dir is the directory the image is stored in, split into a list of strings
so one example: ["folder1","folder1child", "image"]
Now, if i want to create a Hierarchy of the whole directory showing all images in the different folders represented as JSON, something like the below.
{
text: 'Folder 1',
children: [{ name: 'image 1' }, { name: 'image 2' }, { name: 'image 2' }],
},
{
text: 'Folder 2',
children: [
{ name: 'folder 2 child folder', children: [{ name: 'image 1' }] },
{ name: 'image 2' },
{ name: 'image 2' },
],
},
How can i successfully archive this?
6 replies