1.16.1 • Published 3 months ago
json-difference v1.16.1
JsonDifference
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?
Example
Installation
yarn add json-difference
Or
<script type="module">
import { getDiff } from 'https://rawgit.com/lukascivil/jsondiffer/master/dist.browser/json-difference.mjs'
</script>
Example
Running example:
yarn example {simple, stress}
Usage
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, especial3: [{}] }
// Get JsonDiff delta
let diff = getDiff(coffee, oil)
let diff2 = getDiff(coffee, oil, true)
console.log(diff)
console.log(diff2)
Output:
{
"added": [
["special2", false],
["especial3/0[]", {}]
],
"removed": [["special", true]],
"edited": [
["color/color1", "black", "red"],
["color/color2", "brown", "blue"]
]
}
{
"added": [
["special2", false],
["especial3[0]", {}]
],
"removed": [["special", true]],
"edited": [
["color.color1", "black", "red"],
["color.color2", "brown", "blue"]
]
}
1.16.1
3 months ago
1.16.0
5 months ago
1.15.8
5 months ago
1.15.7
9 months ago
1.9.1
1 year ago
1.9.0
1 year ago
1.8.2
2 years ago
1.8.0
2 years ago
1.2.0
2 years ago
1.1.7
2 years ago
1.6.1
2 years ago
1.1.6
2 years ago
1.6.0
2 years ago
1.1.5
2 years ago
1.5.0
2 years ago
1.4.0
2 years ago
1.3.0
2 years ago
1.2.1
2 years ago
1.0.4
4 years ago
1.0.2
6 years ago
1.0.0
6 years ago