I am trying to return a taxonomy tree in the JSON format but the issue is that I would like to have it nested based on the depth of the term, like the following format: What is the easiest way to do this?
{
label: 'term1',
children: [
{ label: 'term1.1' },
{ label: 'term1.2',
children: [label: 'term1.2.1'] }
]
},
{
label: 'term2',
children: [
{ label: 'term2.1' }
]
}
];
Thanks,