I'm currently working on displaying tables.
But im stuck because the data structure is super nested. This is the original structure:
{
"key": "parent_table",
"title": "parent_table",
"type": "table",
"children": [
{
"key": "parent_record[0]",
"title": "parent_record[0]",
"children": [
{
"key": "parent_field_1",
"title": "parent_field_1",
"type": "input",
"children": [
{
"key": "parent_field_1_value",
"title": "parent_field_1_value",
"value": "2122",
"type": "input"
}
]
},
{
"key": "parent_field_2",
"title": "parent_field_2",
"type": "table",
"children": [
{
"key": "children_1_table",
"title": "tablerow[1]",
"children": [
{
"key": "column1",
"title": "column1",
"type": "input",
"children": [
{
"key": "column1_value",
"title": "column1_value",
"value": "column1_value",
"type": "input"
}
]
},
{
"key": "column2",
"title": "column2",
"type": "input",
"children": [
{
"key": "column2_value",
"title": "column2_value",
"value": "column2_value",
"type": "input"
}
]
}
]
}
]
}
]
},
{
"key": "parent_record[1]",
"title": "parent_record[1]",
"children": [
{
"key": "parent_field_1",
"title": "parent_field_1",
"type": "input",
"children": [
{
"key": "parent_field_1_value",
"title": "parent_field_1_value",
"value": "2122",
"type": "input"
}
]
},
{
"key": "parent_field_2",
"title": "parent_field_2",
"type": "table",
"children": [
{
"key": "children_2_table",
"title": "tablerow[1]",
"children": [
{
"key": "column1",
"title": "column1",
"type": "input",
"children": [
{
"key": "column1_value",
"title": "column1_value",
"value": "column1_value",
"type": "input"
}
]
},
{
"key": "column2",
"title": "column2",
"type": "input",
"children": [
{
"key": "column2_value",
"title": "column2_value",
"value": "column2_value",
"type": "input"
}
]
}
]
}
]
}
]
}
]
}
And this is the expected data structure:
[
{
"key": "parent_table",
"title": "parent_table",
"type": "table",
"children": [
{
"key": "parent_record[0]",
"title": "parent_record[0]",
"children": [
{
"key": "parent_field_1",
"title": "parent_field_1",
"type": "input",
"children": [
{
"key": "parent_field_1_value",
"title": "parent_field_1_value",
"value": "2122",
"type": "input"
}
]
}
]
},
{
"key": "parent_record[1]",
"title": "parent_record[1]",
"children": [
{
"key": "parent_field_1",
"title": "parent_field_1",
"type": "input",
"children": [
{
"key": "parent_field_1_value",
"title": "parent_field_1_value",
"value": "2122",
"type": "input"
}
]
}
]
}
]
},
{
"key": "parent_field_2",
"title": "parent_field_2",
"type": "table",
"children": [
{
"key": "children_1_table",
"title": "tablerow[1]",
"children": [
{
"key": "column1",
"title": "column1",
"type": "input",
"children": [
{
"key": "column1_value",
"title": "column1_value",
"value": "column1_value",
"type": "input"
}
]
},
{
"key": "column2",
"title": "column2",
"type": "input",
"children": [
{
"key": "column2_value",
"title": "column2_value",
"value": "column2_value",
"type": "input"
}
]
}
]
}
]
},
{
"key": "parent_field_2",
"title": "parent_field_2",
"type": "table",
"children": [
{
"key": "children_2_table",
"title": "tablerow[1]",
"children": [
{
"key": "column1",
"title": "column1",
"type": "input",
"children": [
{
"key": "column1_value",
"title": "column1_value",
"value": "column1_value",
"type": "input"
}
]
},
{
"key": "column2",
"title": "column2",
"type": "input",
"children": [
{
"key": "column2_value",
"title": "column2_value",
"value": "column2_value",
"type": "input"
}
]
}
]
}
]
}
]
Basically the recursive function will pull the children table out from the parent and make the children table same layer with parent table.