I am trying to remove duplicate JSON Objects from the array in ServiceNow. Tried below code but it does not remove the duplicate. I want to compare both name & city.
var arr1 = '[{"name":"Pune","city":"India"},{"name":"Pune","city":"India"}]';
var splitlen = JSON.parse(arr1);
alert(splitlen.length);
var uniqueArray = [];
var uniqueJson = {};
for(i=0;i<splitlen.length;i++)
    {
        
        if(uniqueArray.indexOf(splitlen[i].name)==-1)
            {
                uniqueArray.push(splitlen[i]);
            }
    }
alert(JSON.stringify(uniqueArray));
Expected output :
[{"name":"Pune","city":"India"}]
 
     
     
     
     
    