Recursion problem programming

MQL5 전문가 라이브러리

작업 종료됨

실행 시간 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

응답함

1
개발자 1
등급
프로젝트
1
0%
중재
0
기한 초과
0
무료

프로젝트 정보

예산
10 - 30 USD
개발자에게
9 - 27 USD
기한
 1 일