I'm able to remove the duplicates from the JSON given below :
var testJSON=[
{
"target": "300.0",
"valueObj": {
"id": 2538
}
},
{
"target": "400.0",
"valueObj": {
"id": 2539
}
},
{
"target": "300.0",
"valueObj": {
"id": 2538
}
},
{
"target": "400.0",
"valueObj": {
"id": 2539
}
},
{
"target": "12.23",
"valueObj": {
"id": 2540
}
}
]
using underscore _uniq property as:
_.uniq(testJSON ,'valueObj.id');
which returns only unique property ie.,
{
"target": "300.0",
"valueObj": {
"id": 2538
}
}
But not displaying other objects . The result that I'm expecting..
[
{
"target": "300.0",
"valueObj": {
"id": 2538
}
},
{
"target": "400.0",
"valueObj": {
"id": 2539
}
},
{
"target": "12.23",
"valueObj": {
"id": 2540
}
}
]