大佬们 请问一下怎么将如下数组格式
[JavaScript] 纯文本查看 复制代码 [
'com.yt.iot.store2.k1.IotStoreK1',
'com.yt.util.HttpUtil',
'com.yt.iot.store2.k1.task.RealTimeRedisStatTask'
]
转换为如下格式
[JavaScript] 纯文本查看 复制代码 [
{
name: 'com',
children: [
{
name: 'yt',
children: [
{
name: 'iot',
children: [
{
name: 'store2',
children: [
{
name: 'k1',
children: [
{ name: 'IotStoreK1' },
{
name: 'task',
children: [{ name: 'RealTimeRedisStatTask' }]
}
]
}
]
}
]
},
{
name: 'util',
children: [{ name: 'HttpUtil' }]
}
]
}
]
}
]
或者如下格式
[JavaScript] 纯文本查看 复制代码 [
{ id: 'com', name: 'com' },
{ id: 'yt', name: 'yt', pid: 'com' },
{ id: 'iot', name: 'iot', pid: 'yt' },
{ id: 'util', name: 'util', pid: 'yt' },
{ id: 'HttpUtil', name: 'HttpUtil', pid: 'util' },
{ id: 'store2', name: 'store2', pid: 'iot' },
{ id: 'k1', name: 'k1', pid: 'store2' },
{ id: 'IotStoreK1', name: 'IotStoreK1', pid: 'k1' },
{ id: 'task', name: 'task', pid: 'k1' },
{ id: 'RealTimeRedisStatTask', name: 'RealTimeRedisStatTask', pid: 'task' }
]
谢谢大佬们~
|