@@ -7,6 +7,7 @@ REMOVE = "REMOVE";
77
88// TYPES
99ARRAY = "ARRAY" ;
10+ NULL = "NULL" ;
1011OBJECT = "OBJECT" ;
1112SCALAR = "SCALAR" ;
1213
@@ -32,6 +33,7 @@ function ValidationException(leftError, rightError) {
3233function getDiffRepresentation ( left , right ) {
3334
3435 function _getType ( v ) {
36+ if ( v === null ) return NULL ;
3537 var type = typeof ( v ) ;
3638 if ( type === 'number' || type === 'string' || type === 'boolean' ) return SCALAR ;
3739 if ( type === 'object' ) {
@@ -102,8 +104,10 @@ function getDiffRepresentation(left, right) {
102104 result = result . concat ( _getScalarsDiff ( null , left [ i ] , null , right [ i ] ) ) ;
103105 } else if ( leftType === OBJECT ) {
104106 result . push ( new Diff ( null , _getJsonsDiff ( left [ i ] , right [ i ] ) , NONE , OBJECT ) ) ;
105- } else {
107+ } else if ( leftType === ARRAY ) {
106108 result . push ( new Diff ( null , _getArraysDiff ( left [ i ] , right [ i ] ) , NONE , ARRAY ) ) ;
109+ } else {
110+ result . push ( new Diff ( null , null , NONE , NULL ) ) ;
107111 }
108112 } else {
109113 result . push ( new Diff ( null , _getInDepthDiff ( left [ i ] , ADD ) , ADD , leftType ) ) ;
@@ -134,8 +138,10 @@ function getDiffRepresentation(left, right) {
134138 result = result . concat ( _getScalarsDiff ( key , left [ key ] , key , right [ key ] ) ) ;
135139 } else if ( leftType === OBJECT ) {
136140 result . push ( new Diff ( key , _getJsonsDiff ( left [ key ] , right [ key ] ) , NONE , OBJECT ) ) ;
137- } else {
141+ } else if ( leftType == ARRAY ) {
138142 result . push ( new Diff ( key , _getArraysDiff ( left [ key ] , right [ key ] ) , NONE , ARRAY ) ) ;
143+ } else {
144+ result . push ( new Diff ( key , null , NONE , NULL ) ) ;
139145 }
140146 } else {
141147 result . push ( new Diff ( key , _getInDepthDiff ( left [ key ] , ADD ) , ADD , leftType ) ) ;
0 commit comments