Currently, I am receiving a JSON object named formDoc
containing data from the backend.
{
"components": [
{
"label": "Textfield1",
"type": "textfield",
"key": "textfield1",
"input": true
},
{ "label": "Radio",
"type": "radiobutton",
"key": "radiobutton1",
"input": true
},]}
Another form I have received is as follows:
{
"components": [
{
"label": "Text2",
"type": "textfield",
"key": "textfield2",
"input": true
},
{ "label": "Checkbox",
"type": "checkbox",
"key": "checkbox1",
"input": true
},
{ "label": "Checkbox2",
"type": "checkbox",
"key": "checkbox2",
"input": true
},]}
Each form contains different components as they are customized by users. I am attempting to split the JSON by keys. For instance, splitting the first one into
{
"label": "Textfield1",
"type": "textfield",
"key": "textfield1",
"input": true
},
and
{ "label": "Radio",
"type": "radiobutton",
"key": "radiobutton1",
"input": true
},
How can I implement this split functionality in Typescript? The challenge lies in splitting the first form into two separate objects and the second one into three separate objects. The issue is not just splitting up the components but also finding a way to store them effectively as you cannot create an "object" list similar to a string.