benjamine / jsondiffpatch

Diff & patch JavaScript objects
MIT License
4.77k stars 464 forks source link

Create new object with changes only #328

Closed janisii closed 1 year ago

janisii commented 1 year ago

Hello, is it possible to use this plugin to output new object with only changes between to json objects?

export const json1 = {
  name: "South America",
  summary: "South America",
  surface: 17840000,
  timezone: [-4, -2],
  demographics: {
    population: 385742554,
    test: [
      {
        status: "GOOD",
        value: 56
      },
    ]
  }
};

export const json2 = {
  name: "Canada",
  summary: "South brrree",
  surface: 17840000,
  timezone: [-4, -2],
  demographics: {
    population: 385742554,
    test: [
      {
        status: "GOOD",
        value: 66
      }
    ]
  }
};

The result should be:

json3 = {
  name: "Canada",
  summary: "South brrree",
   demographics: {
    test: [
      {
        status: "GOOD",
        value: 66
      }
    ]
   }
}

Thanks.