@@ -7,6 +7,7 @@ REMOVE = "REMOVE";
7
7
8
8
// TYPES
9
9
ARRAY = "ARRAY" ;
10
+ NULL = "NULL" ;
10
11
OBJECT = "OBJECT" ;
11
12
SCALAR = "SCALAR" ;
12
13
@@ -32,6 +33,7 @@ function ValidationException(leftError, rightError) {
32
33
function getDiffRepresentation ( left , right ) {
33
34
34
35
function _getType ( v ) {
36
+ if ( v === null ) return NULL ;
35
37
var type = typeof ( v ) ;
36
38
if ( type === 'number' || type === 'string' || type === 'boolean' ) return SCALAR ;
37
39
if ( type === 'object' ) {
@@ -102,8 +104,10 @@ function getDiffRepresentation(left, right) {
102
104
result = result . concat ( _getScalarsDiff ( null , left [ i ] , null , right [ i ] ) ) ;
103
105
} else if ( leftType === OBJECT ) {
104
106
result . push ( new Diff ( null , _getJsonsDiff ( left [ i ] , right [ i ] ) , NONE , OBJECT ) ) ;
105
- } else {
107
+ } else if ( leftType === ARRAY ) {
106
108
result . push ( new Diff ( null , _getArraysDiff ( left [ i ] , right [ i ] ) , NONE , ARRAY ) ) ;
109
+ } else {
110
+ result . push ( new Diff ( null , null , NONE , NULL ) ) ;
107
111
}
108
112
} else {
109
113
result . push ( new Diff ( null , _getInDepthDiff ( left [ i ] , ADD ) , ADD , leftType ) ) ;
@@ -134,8 +138,10 @@ function getDiffRepresentation(left, right) {
134
138
result = result . concat ( _getScalarsDiff ( key , left [ key ] , key , right [ key ] ) ) ;
135
139
} else if ( leftType === OBJECT ) {
136
140
result . push ( new Diff ( key , _getJsonsDiff ( left [ key ] , right [ key ] ) , NONE , OBJECT ) ) ;
137
- } else {
141
+ } else if ( leftType == ARRAY ) {
138
142
result . push ( new Diff ( key , _getArraysDiff ( left [ key ] , right [ key ] ) , NONE , ARRAY ) ) ;
143
+ } else {
144
+ result . push ( new Diff ( key , null , NONE , NULL ) ) ;
139
145
}
140
146
} else {
141
147
result . push ( new Diff ( key , _getInDepthDiff ( left [ key ] , ADD ) , ADD , leftType ) ) ;
0 commit comments