For my project, I am designing a data structure that utilizes JSON. My goal is to create an efficient method for searching and editing the JSON object. Which structure would be considered standard in this scenario? Is there a preferred way to implement either of these options?
The object with ID 2 has a parent with ID 1.
const items = [
{
id: 1,
title: 'First',
UUID: 123,
action : null,
isFolder: true,
parent: null,
},
{
id: 2,
title: 'Second',
UUID: 123,
action : null,
isFolder: false,
parent: 1,
},
{
id: 3,
title: 'Third',
UUID: 123,
action : null,
isFolder: false
parent: null,
},
]
Structure 2
const items = [
{
id: 1,
title: 'First',
UUID: 123,
action : null,
isFolder: true,
children: [
{
id: 2,
title: 'Second',
UUID: 123,
action : null,
isFolder: false,
children: [],
},
]
},
{
id: 3,
title: 'Third',
UUID: 123,
action : null,
isFolder: false
children: [],
},
]