Using the value from an array of object I'm trying to generate an another array of objects with a different structure than that of the original array.
In the following example arrays you can see that from the key:value pairs the key is changing between the Source array and Result array but the values are same. I had tried some code but not worthwhile to share. What logic or method can be used in this case to generate the object structure mentioned below
Source array
[
{
"node": {
"Charecter": "Hulk",
"Publisher": "Marvel",
"Movie": "Avengers"
}
},
{
"node": {
"Charecter": "Wolverine",
"Publisher": "Marvel",
"Movie": "X-Men"
}
},
{
"node": {
"Charecter": "Superman",
"Publisher": "DC",
"Movie": "Man of steel"
}
}
]
Result array
[
{
"Franchise": "Marvel",
"Data": [
{
"Lead": "Hulk",
"In": "Avengers"
},
{
"Lead": "Wolverine",
"In": "X-Men"
}
]
},
{
"Franchise": "DC",
"Data": [
{
"Lead": "Superman",
"In": "Man of steer"
}
]
},
]