Unique Values in JSON Object Array
by santhosh lanka
JavaScript
var data = [{"name":"Lenovo Thinkpad 41A4298","website":"google"},
{"name":"Lenovo Thinkpad 41A2222","website":"google"},
{"name":"Lenovo Thinkpad 41Awww33","website":"yahoo"},
{"name":"Lenovo Thinkpad 41A424448","website":"google"},
{"name":"Lenovo Thinkpad 41A429rr8","website":"ebay"},
{"name":"Lenovo Thinkpad 41A429ff8","website":"ebay"},
{"name":"Lenovo Thinkpad 41A429ss8","website":"rediff"},
{"name":"Lenovo Thinkpad 41A429sg8","website":"yahoo"}];
var uniqueNames = [];
for(i = 0; i< data.length; i++){
if(uniqueNames.indexOf(data[i].website) === -1){
uniqueNames.push(data[i].website);
}
}
for(i = 0; i< uniqueNames.length; i++){
alert(uniqueNames[i]);
}