I am trying to filter data from a response and remove duplicate elements and push data into an array, my api response looks like this:
{
"_id":"0",
"yacht_id":"200",
"promo_id":"300",
"blocked_thru":"promotions",
"dates":"2017-08-23T00:00:00.000Z",
},
{
"_id":"1",
"booking_id":{
"_id":"100",
"booking_id":"BK163041494",
},
"blocked_thru":"booked",
"dates":"2017-08-30T00:00:00.000Z",
},
{
"_id":"2",
"booking_id":{
"_id":"100",
"booking_id":"BK163041494",
},
"blocked_thru":"booked",
"dates":"2017-08-30T00:00:00.000Z",
}
From the answer above, if "object_id" exists in the object and "booking_id._id" is the same, I need to filter and click only unique objects in the array.
I need an answer as shown below:
{
"_id":"0",
"yacht_id":"200",
"promo_id":"300",
"blocked_thru":"promotions",
"dates":"2017-08-23T00:00:00.000Z",
},
{
"_id":"1",
"booking_id":{
"_id":"100",
"booking_id":"BK163041494",
},
"blocked_thru":"booked",
"dates":"2017-08-30T00:00:00.000Z",
},
Any help would be appreciated. Thank.