- 论坛徽章:
- 0
|
想实现linux目录结构转成规定的json格式:
[root@test test]# tree
.
├── 1
│ └── 11
│ ├── 1111.txt
│ ├── 111.txt
│ ├── 11.txt
│ └── test1
│ └── test1.txt
├── 2
│ └── 21
│ └── 21.txt
└── test.txt
转换成:
[
{
'text': '1',
'children': [
{
'text': '11',
'children': [
{
'text': '11.txt'
},
{
'text': '111.txt'
},
{
'text': '1111.txt'
},
{
'text': 'test1',
'children': [
{
'text': '11.txt'
}
]
}
],
},
]
},
{
'text': '2',
'children': [
{
'text': '21',
'children': [
{
'text': '21.txt'
}
],
},
]
},
{
'text': 'test.txt'
},
]
|
|