❔ 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?
3 Replies
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
You need to put it into tree data structure, which you then serialize into JSON.
like this
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.