A problem of data conversion

recently encountered a data conversion problem, as follows:
for example, metadata is like this:

[{
  name: "a",
  children: [{
    name: "b",
    children: [{
      name: "c"
    },{
      name: "d",
    }]
  }]
}, {
  name: "f",
  children: [{
    name: "g",
    children: [{
      name: "h"
    },{
      name: "i",
    }]
  }]
}]
The level of

is uncertain. I know to use recursion, but I want to stuff it in an object. It"s easy to wrap around. I"ve been thinking silly. Do you have any ideas?

Mar.17,2021

var v = [
  { "name": "a" },
  { "name": "a.b" },
  { "name": "a.b.c" },
  { "name": "a.b.d" },
  { "name": "f" },
  { "name": "f.g" },
  { "name": "f.g.h" },
  { "name": "f.g.i" }
]; //v 
m = {};
v.forEach(o=>{
    l = o["name"].split('.');
    t = m;
    l.forEach(obj=>{
        if(t[obj] === undefined)t[obj] = {};
        t = t[obj];
    });
})

//
function f(m){
    var res = [];
    var k = [];
    for(var key in m){
        k.push(key);
    }
    for(var i in k){
        var obj = {"name": k[i]};
        if(Object.keys(m[k[i]]).length !== 0)obj.children = f(m[k[i]]);
        res.push(obj);
    }
    return res;
}

r = f(m);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bb46-2c2c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bb46-2c2c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?