Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140762

How to delete full duplicate values from JSON

$
0
0

I have 2 JSON objects as

obj1 = [
  {
    "start": "2019-11-15T00:00:00",
    "end": "2019-11-15T23:59:59",
    "Room Night": "2019-11-15"
  },
  {
    "start": "2019-11-13T00:00:00",
    "end": "2019-11-13T23:59:59",
    "Room Night": "2019-11-13"}
  {
    "start": "2019-11-14T00:00:00",
    "end": "2019-11-14T23:59:59",
    "Room Night": "2019-11-14"
  }
]

and

obj2 = [
  {
    "start": "2019-11-15T00:00:00", 
    "end": "2019-11-15T23:59:59", 
    "Room Night": "2019-11-15"
  },
  {
    "start": "2019-11-13T00:00:00",
    "end": "2019-11-13T23:59:59",
    "Room Night": "2019-11-13"
  },
  {
    "start": "2019-11-16T00:00:00",
    "end": "2019-11-16T23:59:59",
    "Room Night": "2019-11-16"
  },
  {
    "start": "2019-11-17T00:00:00", 
    "end": "2019-11-17T23:59:59", 
    "Room Night": "2019-11-17"
  }
] 

In the above 2 JSONs, i have 2 duplicate "Room Nights" , dates as 2019-11-13 and 2019-11-15. I want to delete the entire duplicate values and get the output as below in JSON format.

[
  {
    "start": "2019-11-14T00:00:00", 
    "end": "2019-11-14T23:59:59", 
    "Room Night": "2019-11-14"
  },
  {
    "start": "2019-11-16T00:00:00",
    "end": "2019-11-16T23:59:59",
    "Room Night": "2019-11-16"
  },
  {
    "start": "2019-11-17T00:00:00", 
    "end": "2019-11-17T23:59:59",
    "Room Night": "2019-11-17"
  }
] 

Could you please help to sort out this.

Regards, Prets.


Viewing all articles
Browse latest Browse all 140762

Latest Images

Trending Articles



Latest Images