Saya sedang mengerjakan proyek menggunakan Webix dan Python/Flask dan saya menemui jalan buntu dengan merender widget tampilan pohon. Masalah saya adalah membangun JSON dengan benar yang dibutuhkan oleh widget. Saya mencoba membuat struktur direktori dari contoh yang diberikan:
Struktur:
. ├── dirone │ └── file ├── dirthree │ ├── somedir │ │ └── anotherfile │ └── somefile ├── dirtwo └── somefile
Keluaran yang diinginkan:
[
{
"value": "dirone",
"path": "dirone",
"type": "folder",
"children": [
{
"value": "file",
"path": "dirone/file",
"type": "file"
}
]
},
{
"value": "dirtwo",
"path": "dirtwo",
"type": "folder",
"children": []
},
{
"value": "dirthree",
"path": "dirthree",
"type": "folder",
"children": [
{
"value": "somefile",
"path": "dirthree/somefile",
"type": "file"
},
{
"value": "somedire",
"path": "dirone/file",
"type": "folder",
"children": [
{
"value": "anotherfile",
"path": "dirthree/somedir/anotherfile",
"type": "file"
}
]
}
]
},
{
"value": "somefile",
"path": "somefile",
"type": "file"
}
]
Saya telah memikirkan hal ini selama dua jam terakhir untuk mencoba mendapatkan metode yang dapat merendernya. Apakah ada metode yang menghasilkan struktur? Bantuan apa pun akan sangat dihargai!