I am trying to format my array that I created from a csv file. After parsing it into the correct format, I need a way to remove duplicates that I run into from the csv file.
Here is an example of the array that I have
[{
"pccs": ["1ADA"],
"markets": [{
"origin": "LAX",
"destination": "DFW"
}, {
"origin": "LAX",
"destination": "IAH"
}, {
"origin": "LAX",
"destination": "IAH"
}, {
"origin": "LAX",
"destination": "IAH"
}]
}, {
"pccs": ["1ABA"],
"markets": [{
"origin": "LAX",
"destination": "JFK"
}]
}]
I am trying to format this to only display a unique set for each element in the list to get a response like this:
[{
"pccs": ["1ADA"],
"markets": [{
"origin": "LAX",
"destination": "DFW"
}, {
"origin": "LAX",
"destination": "IAH"
}]
}, {
"pccs": ["1ABA"],
"markets": [{
"origin": "LAX",
"destination": "JFK"
}]
}]
I'm leaning towards using the filter() function, but not sure how to implement it with a list of objects. Would i have to created a nested loop to access each individual element?