[{Title:"中交大酒店",Address:"柳州解放北路1号",Content:"undefined",Points:"109.419662 |24.322459",IsOpen:0,Icon:{w:21,h:21,l:0,t:0,x:6,lb:5}},
{Title:"柳州市艺术宾馆",Address:"柳州市八一路8号",Content:"undefined",Points:"109.415949|24.325656",IsOpen:0,Icon:{w:21,h:21,l:0,t:0,x:6,lb:5}},
{Title:"柳州市艺术宾馆",Address:"柳州市八一路8号",Content:"undefined",Points:"109.415949|24.325656",IsOpen:0,Icon:{w:21,h:21,l:0,t:0,x:6,lb:5}},
{Title:"柳安大厦宾馆",Address:"柳州市文笔路91号",Content:"undefined",Points:"109.417615|24.317366",IsOpen:0,Icon:{w:21,h:21,l:0,t:0,x:6,lb:5}}]
把上面重复的【柳州市艺术宾馆】去掉,留一个
[{Title:"中交大酒店",Address:"柳州解放北路1号",Content:"undefined",Points:"109.419662 |24.322459",IsOpen:0,Icon:{w:21,h:21,l:0,t:0,x:6,lb:5}},
{Title:"柳州市艺术宾馆",Address:"柳州市八一路8号",Content:"undefined",Points:"109.415949|24.325656",IsOpen:0,Icon:{w:21,h:21,l:0,t:0,x:6,lb:5}},
{Title:"柳安大厦宾馆",Address:"柳州市文笔路91号",Content:"undefined",Points:"109.417615|24.317366",IsOpen:0,Icon:{w:21,h:21,l:0,t:0,x:6,lb:5}}]
我想到的方法是先转换为对象,然后再处理重复数据。
数据库中有重复数据,建议都不要把重复数据查出来,呵呵,要不然就只能,楼上所说的,转成对象,才可以去重复了
//JOSN数组去重的算法 JS
Array.prototype.unique1 = function () {
var res = [this[0]];
for (var i = 1; i < this.length; i++) {
var repeat = false;
for (var j = 0; j < res.length; j++) {
if (this[i]== res[j]) {
repeat = true;
break;
}
}
if (!repeat) {
res.push(this[i]);
}
}
return res;
}