I have a multi dimensional array that I need to convert into the array2 structure. I've tried various methods, but all of them have resulted in bulky code and lots of iteration. Is there an easier way to accomplish this task?
I am new to Angular and JavaScript.
var array1=[
{
"id": 1,
"name": "Johny",
"category": [
{
"id": 12,
"name": "GUI",
"status": {
"id": 123,
"status": "working",
"name": "GUI"
}
},
// more nested objects here
]
},
// more arrays of objects here
]
I want to transform this array into array2.
var array2=[
{
"id": 1,
"name": "Johny",
"category": [
{
"id": 12,
"name": "GUI",
"data": [
// transformed data structure
]
},
// more transformed data structures
]
},
// more transformed arrays here
]
Output should be in the array2 structure. Thank you in advance.