1var data = [{
2 "name": "Peter",
3 "age": 30,
4 "hair color": "brown"
5}, {
6 "name": "Steve",
7 "age": 55,
8 "hair color": "blonde"
9}, {
10 "name": "Steve",
11 "age": 55,
12 "hair color": "blonde"
13}]
14
15 data = this.data.filter((obj, pos, arr) => {
16 return arr
17 .map(mapObj => mapObj.name)
18 .indexOf(obj.name) == pos;
19 });
20
21console.log(data);
22/*
23[{
24 "name": "Peter",
25 "age": 30,
26 "hair color": "brown"
27}, {
28 "name": "Steve",
29 "age": 55,
30 "hair color": "blonde"
31}]
32*/
1var json = [
2 {"text":"menu1","parent":"#","id":"128102"},
3 {"text":"menu1.1","parent":"128102","id":"128103"},
4 {"text":"menu1.1","parent":"128102","id":"128103"}
5];
6
7var ids = [];
8var clean = [];
9
10$.each(json, function(index, value) {
11 if($.inArray(value.id, ids) == -1)
12 {
13 ids.push(value.id);
14 clean.push(value);
15 }
16});