Input: {
"drag": {
"misc": {
"prog": {
"ID": {
"type": "name",
"value": "ABC"
},
"ID": {
"type": "standard",
"value": "PQR"
}
}
}
},
"peak": {
"bird": {
"tech": {
"pl": {
"ID": {
"type": "room",
"value": "123"
},
"ID": {
"type": "sport",
"value": "football"
}
}
}
}
},
"ID": {
"type": "browser",
"value": "google"
},
"ID": {
"type": "day",
"value": "Wednesday"
}
}
Required Output:
{
"drag": {
"misc": {
"prog": {
"ID": {
"name": "ABC",
"standard": "PQR"
}
}
}
},
"peak": {
"bird": {
"tech": {
"pl": {
"ID": {
"room": "123",
"sport": "football"
}
}
}
}
},
"ID": {
"browser": "google",
"day": "Wednesday"
}
}
To summarize the requirement, I need to consolidate ID key w.r.t type and value keys.
Please note: This is just an example payload. Actual payload can have n number of nested objects. However, the ID will have same keys i.e. type and value. Manually structuring the payload is not an option.