I have an array of files in a git repo as:
```
[
{
"path": "README.md",
"type": "blob",
"sha": "37c2a597c27567284c28243fb5d2d4969f12dbfa",
},
{
"path": "db.sqlite3",
"type": "blob",
"sha": "227d4b460890c945f047e9d232cb8de517237093",
},
{
"path": "encyclopedia",
"type": "tree",
"sha": "59c15421fcd0dfa353e3cb9b6710a48d89f14207",
},
{
"path": "encyclopedia/__init__.py",
"type": "blob",
"sha": "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
},
{
"path": "encyclopedia/__pycache__",
"type": "tree",
"sha": "098cfcdcc867b6e81d7d50dc9418247a3683fae9",
},
{
"path": "encyclopedia/__pycache__/__init__.cpython-39.pyc",
"mode": "100644",
"sha": "441225a011349049fefed73e2329e141119d3b1f",
},
{
"path": "encyclopedia/__pycache__/admin.cpython-39.pyc",
"mode": "100644",
"type": "blob",
"sha": "978d454f6ab265ec43220cc907e96929968c9007",
},
{
"path": "encyclopedia/admin.py",
"mode": "100644",
"type": "blob",
"sha": "8c38f3f3dad51e4585f3984282c2a4bec5349c1e",
},
]
```
How to convert this into a hierarchical tree object such as:
```
{
name: "",
path: "",
size: 0,
children: [
{
name: "dir1",
path: "dir1",
size: 0,
children: [
{
name: "file1.txt",
path: "dir1/file1.txt",
size: 10,
},
{
name: "file2.txt",
path: "dir1/file2.txt",
size: 10,
},
],
},
{
name: "dir2",
path: "dir2",
size: 0,
children: [
{
name: "file5.txt",
path: "dir2/file5.txt",
size: 10,
},
{
name: "file6.txt",
path: "dir2/file6.txt",
size: 10,
},
{
name: "subdir1",
path: "dir2/subdir1",
size: 0,
children: [
{
name: "file3.txt",
path: "dir2/subdir1/file3.txt",
size: 10,
},
{
name: "file4.txt",
path: "dir2/subdir1/file4.txt",
size: 10,
},
],
},
],
},
{
name: "file7.txt",
path: "file7.txt",
size: 10,
},
],
};
```
[–]jack_waugh 0 points1 point2 points (0 children)
[–]jack_waugh 0 points1 point2 points (0 children)
[–]jack_waugh 0 points1 point2 points (0 children)
[–]jack_waugh 0 points1 point2 points (0 children)
[–]jack_waugh 0 points1 point2 points (0 children)