Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

diff

diff(Any, Any, { unordered?: Boolean }, String): Diff

Returns the structural diference between two values. It returns an Difference. When comparing objects it can be either ordered or unordered. By default is ordered this means that two object are not going to have a difference if their key value pairs are in the same order. To change this behaviour specify the diffConfig parameter with {unordered: true}

Example:

        
     
1
2
3
4
5
6
7
%dw 2.0
import * from dw::util::Diff
output application/json
var a = { age: "Test" }
var b = { age: "Test2" }
---
 a diff b
Output:

        
     
1
2
3
4
5
6
7
8
9
10
{
"matches": false,
 "diffs": [
   {
     "expected": "\"Test2\"",
     "actual": "\"Test\"",
     "path": "(root).age"
   }
 ]
}