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 behavior 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"
   }
 ]
}

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+