Hello and welcome to the forum :)
The structure of the API GET responses follows a fixed definition, based on the chosen relations & columns - there is currently no option to change how the JSON structure is created.
To return a dynamic number of children, you could either retrieve the parent and use a sub query column to return children as an array or list - with this as a possible result:
[
{
"0(parent)": {
"id": 1,
"children": [
87,
99
]
}
},
{
"0(parent)": {
"id": 2,
"children": [
45,
87
]
}
}
]
Or you could retrieve the children and include the parent data as such:
[
{
"0(child)": {
"id": 45,
"name": "ABC"
},
"1(parent)": {
"id":2
}
},
{
"0(child)": {
"id": 87,
"name": "ABC"
},
"1(parent)": {
"id": 2
}
}
]