Trabajo finalizado
Plazo de ejecución 36 segundos
Tarea técnica
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
Han respondido
1
Evaluación
Proyectos
1
0%
Arbitraje
0
Caducado
0
Libre
Información sobre el proyecto
Presupuesto
10 - 30 USD
Plazo límite de ejecución
a 1 día(s)