-1
我想將文件夾結構(包括文件夾,json文件及其內容)映射到樹視圖(如JSON對象)中。我想問問是否有人會爲我提供了一個功能,即loadFolder(「/ A」)會加載以下文件夾結構...將文件夾結構加載到NodeJS中的樹視圖JSON對象中
/A
/a/file1.json
/a/file2.json
/a/b/file1.json
/A/b/C
...將導致進入這個JSON對象:
{
path: "/a",
name: "a",
type: "folder",
subnodes: [
{
path: "https://stackoverflow.com/a/file1.json",
name: "file1.json",
type: "file",
content: {
// file content here
}
},
{
path: "https://stackoverflow.com/a/file2.json",
name: "file2.json",
type: "file",
content: {
// file content here
}
},
{
path: "https://stackoverflow.com/a/b",
name: "b",
type: "folder",
subnodes: [
{
path: "https://stackoverflow.com/a/b/file1.json",
name: "file1.json",
type: "file",
content: {
// file content here
}
},
{
path: "https://stackoverflow.com/a/b/c",
name: "c",
type: "folder",
subnodes: []
}
]
}
]
}