I am in possession of an object with various properties, ranging from arrays to objects.
My goal is to transform the object so that each sub field is encapsulated within an array.
For instance:
"head": {
"text": "Main title",
"sub": {
"value": "next"
},
"place": "secondary"
}
The 'head' field contains an object. I aim to have the object enclosed in an array like this:
"head": [{
"text": "Main title",
"sub": {
"value": "next"
},
"place": "secondary"
}]
I have recognized that maintaining the structure consistent for every item is essential.
I attempted to achieve this using interfaces but encountered issues as the object type varies. As a result, I seek to retain the structure.
If there are better methods to convert the object into a suitable interface, I would appreciate hearing about them.
Thank you!