【发布时间】:2023-03-03 05:54:22
【问题描述】:
我想创建一个树状嵌套结构作为 obj(后来的 JSON),但很难正确地做到这一点。
我想转换这个:
root/app/index.html
进入这个:
{
type: 'box',
name: 'root'
children: {
type: 'box',
name: 'app',
children: {
type: 'item',
name: 'index.html'
}
}
}
我如何通过代码做到这一点有什么建议?
【问题讨论】:
-
是的,尽量不要让我的问题超载所以不要放这么简单的东西,我的问题开始了,然后我尝试做 push() :(
标签: javascript arrays json object tree