Computes the difference between two objects and returns an intuitive result. No matter how big your JSON is, the diff will be returned pretty fast.
The question you should ask is: Given my old structure what was changed, removed or added to the new structure?
yarn add json-difference
Or
<script type="module">
import { getDiff } from 'https://rawgit.com/lukascivil/jsondiffer/master/dist.browser/json-difference.mjs'
</script>
Running example:
yarn example {simple, stress}
Method:
getDiff(oldStruct, newStruct)
Returns the structural difference between oldStruct
and newStruct
.
Simple usage:
import { getDiff } from 'json-difference'
const coffee = { color: { color1: 'black', color2: 'brown' }, special: true }
const oil = { color: { color1: 'red', color2: 'blue' }, special2: false }
let diff = getDiff(coffee, oil)
console.log(diff)
Output:
{
"added": [["special2", false]],
"removed": [["special", true]],
"edited": [
["color/color1", "black", "red"],
["color/color2", "brown", "blue"]
]
}