У меня есть массив, содержащий объекты, которые могут иметь n-й уровень глубины.
Примерно так:
const settings = [
{path: '/templates/pictures.php', url: '/pictures', label: 'Pictures', component: 'tab', template: 'default'},
{path: '/templates/post-article.php', url: '/user/:username', component: 'table', template: 'default', children:[
{path: '/templates/post-article-highlights.php', url: '/user/:username/highlights', component: 'table', template: 'default', children:[
{path: '/templates/post-article-highlights.php', url: '/user/:username/highlights', component: 'table', template: 'default'}
]}
]}
]
Мне нужно добавить в другой массив только свойство 'Url' и свойство children, если оно есть, но с сохранением глубины.
Итак, новый массив должен выглядеть так:
const newArray = [
{url: '/pictures'},
{url: '/user/:username', children:[
{url: '/user/:username/highlights', children:[
{url: '/user/:username/highlights'}
]}
]}
]
Вы можете мне помочь?
Спасибо