let jsonData = [
{"name": "John", "age": 30, "department": "Sales"},
{"name": "Alice", "age": 25, "department": "Marketing"},
{"name": "John", "age": 30, "department": "Sales"},
{"name": "Bob", "age": 35, "department": "IT"},
{"name": "Alice", "age": 25, "department": "Marketing"},
{"name": "Eva", "age": 28, "department": "HR"}
];
// 使用 Set 数据结构进行去重
let uniqueData = Array.from(new Set(jsonData.map(JSON.stringify))).map(JSON.parse);
console.log(uniqueData);
复杂的 JSON 数据去重 new Set 去重
最新推荐文章于 2024-08-31 20:02:26 发布