Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js remove json value duplicates

var data = [{
    "name": "Peter",
    "age": 30,
    "hair color": "brown"
}, {
    "name": "Steve",
    "age": 55,
    "hair color": "blonde"
}, {
    "name": "Steve",
    "age": 55,
    "hair color": "blonde"
}]

 data = this.data.filter((obj, pos, arr) => {
   return arr
     .map(mapObj => mapObj.name)
     .indexOf(obj.name) == pos;
 });

console.log(data);
/*
[{
    "name": "Peter",
    "age": 30,
    "hair color": "brown"
}, {
    "name": "Steve",
    "age": 55,
    "hair color": "blonde"
}]
*/
Comment

remove duplicate json object from array javascript

const temp =  [{first: 569, second: "789", third: "458"},  {first: 476, second : "147", third: "369"},  {first: 100, second: "200", third: "300"},  {first: 100, second: "200", third: "300"},   {first: 100, second: "200", third: "300"}];

const result = [...new Set(temp.map(obj => JSON.stringify(obj)))]
                 .map(str => JSON.parse(str));
console.log(result);
Comment

Remove Duplicate objects from JSON

//change is
     while( $row = mysqli_fetch_array( $result ))
    { 
		$response[] = $row;
	}
//with this
while($row = mysqli_fetch_array($result))
{
    $response['id'] = $row['id'];
    $response['name'] = $row['name'];
    $response['password'] = $row['password'];
    $response['email'] = $row['email'];
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: next js material ui typescript 
Javascript :: javascript string startswith 
Javascript :: antd modal hide ok button 
Javascript :: react router last page 
Javascript :: jquery remove option from select 
Javascript :: referenceerror window is not defined ckeditor 
Javascript :: javascript string format 
Javascript :: javascript run command 
Javascript :: jquery find checkbox by value 
Javascript :: create react app deployment heroku 
Javascript :: window.location.href 
Javascript :: regex repeat n times 
Javascript :: javascript mysql datetime 
Javascript :: force a component to rerender 
Javascript :: get file extension node 
Javascript :: javascript remove duplicates from array 
Javascript :: iframe reload parent page 
Javascript :: node array 
Javascript :: jquery check if class exists 
Javascript :: check checkbox based on value using jquery 
Javascript :: class element in javascript 
Javascript :: js escape characters 
Javascript :: js events 
Javascript :: angular refresh token 
Javascript :: javascript get element by multiple class names 
Javascript :: convert date format from yyyy-mm-dd to dd-mm-yyyy using value javascript 
Javascript :: get hash js 
Javascript :: javascript dynamic import 
Javascript :: loop over string js 
Javascript :: javascript check if null 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =