I'm receiving the following data in my JS from a WebService :
{
"fire": {
"totalOccurence": 2,
"statsByCustomer": [
{
"idCustomer": 1,
"occurence": 1
},
{
"idCustomer": 2,
"occurence": 1
}
]
},
"flood": {
"totalOccurence": 1,
"statsByCustomer": [
{
"idCustomer": 1,
"occurence": 1
}
]
}
}
What's the fastest way to create the following object as a result :
{
"1": {
"fire": 1,
"flood": 1
},
"2": {
"fire": 1,
"flood": 0
}
}
I'm actually doing multiple forEach to format the data myself, but i think it's pretty ugly and not efficient.. PS : the key for the result map is the customer Id
Any idea on how to do this the right way?
Thanks for your help !