仕事が完了した
実行時間36 秒
指定
i am trying to write a function that takes a flat data format which uses a id and a parentId to establish relationships. I know I need to use recursion but I need help understanding how to get it in a specific JSON model.
Here is the flat source data, the id's are guids as you can see.
{"id":"e6168d55-1974-e411-80e0-005056971214","parentId":"","label":"OGC File List"}
{"id":"17168d55-1974-e411-80e0-005056971214","parentId":"e6168d55-1974-e411-80e0-005056971214","label":"Accounting"}
{"id":"h37s8d55-1974-e411-80e0-005056971214","parentId":"17168d55-1974-e411-80e0-005056971214","label":"Policy"}
{"id":"f8ke6d55-1974-e411-80e0-005056971214","parentId":"17168d55-1974-e411-80e0-005056971214","label":"Policy"}
Below is the model I need to create. I only need help with the properties id: inode: which indicates the node has children and the branch which is the array of child objects. Building the branches is what confounds me the most. I appreciate any assistance or direction in advance!
[
{
id: 'folder_1',
label: 'This is Folder 1',
inode: true,
open: false,
icon: 'folder'
branch:
[
{
id: 'sub-item_x',
label: 'This is File X',
inode: false,
icon: 'file'
},
...
]
},
{
id: 'file_1',
label: 'This is File 1',
inode: false,
icon: 'file'
},
...
]
Job Overview
Type Fixed-Price
Budget $25.00
Posted December 4 2014, 4:44 PM
Planned Start Dec. 4 2014
Delivery Date Dec. 5 2014
Visibility Public
Category Software Development
Sub-category Scripts & Utilities
Here is the flat source data, the id's are guids as you can see.
{"id":"e6168d55-1974-e411-80e0-005056971214","parentId":"","label":"OGC File List"}
{"id":"17168d55-1974-e411-80e0-005056971214","parentId":"e6168d55-1974-e411-80e0-005056971214","label":"Accounting"}
{"id":"h37s8d55-1974-e411-80e0-005056971214","parentId":"17168d55-1974-e411-80e0-005056971214","label":"Policy"}
{"id":"f8ke6d55-1974-e411-80e0-005056971214","parentId":"17168d55-1974-e411-80e0-005056971214","label":"Policy"}
Below is the model I need to create. I only need help with the properties id: inode: which indicates the node has children and the branch which is the array of child objects. Building the branches is what confounds me the most. I appreciate any assistance or direction in advance!
[
{
id: 'folder_1',
label: 'This is Folder 1',
inode: true,
open: false,
icon: 'folder'
branch:
[
{
id: 'sub-item_x',
label: 'This is File X',
inode: false,
icon: 'file'
},
...
]
},
{
id: 'file_1',
label: 'This is File 1',
inode: false,
icon: 'file'
},
...
]
Job Overview
Type Fixed-Price
Budget $25.00
Posted December 4 2014, 4:44 PM
Planned Start Dec. 4 2014
Delivery Date Dec. 5 2014
Visibility Public
Category Software Development
Sub-category Scripts & Utilities
応答済み
1
評価
プロジェクト
1
0%
仲裁
0
期限切れ
0
暇
プロジェクト情報
予算
10 - 30 USD
開発者用
9
- 27
USD
締め切り
最高 1 日