@@ -72,7 +72,7 @@ func (w *WI2LDiffer) convertPatchToDiffEntries(patch jsondiff.Patch) []DiffEntry
72
72
FromValue : w .formatPatchValue (op .OldValue ),
73
73
ToValue : w .formatPatchValue (op .Value ),
74
74
// For reconstruction compatibility, use old value type
75
- ValueType : w .inferValueType (op .OldValue ),
75
+ ValueType : w .inferValueType (op .OldValue ),
76
76
})
77
77
case "move" :
78
78
// Handle move operations - could be array reordering
@@ -104,12 +104,12 @@ func (w *WI2LDiffer) postProcessArrays(diffs []DiffEntry, json1, json2 string) [
104
104
// Always consolidate any array element changes to whole array operations
105
105
arrayChanges := make (map [string ][]DiffEntry )
106
106
var result []DiffEntry
107
-
107
+
108
108
// Parse original JSONs once
109
109
var obj1 , obj2 interface {}
110
110
json .Unmarshal ([]byte (json1 ), & obj1 )
111
111
json .Unmarshal ([]byte (json2 ), & obj2 )
112
-
112
+
113
113
for _ , diff := range diffs {
114
114
if w .isArrayElementPath (diff .FullPath ) {
115
115
arrayPath := w .getArrayPathFromElement (diff .FullPath )
@@ -118,18 +118,18 @@ func (w *WI2LDiffer) postProcessArrays(diffs []DiffEntry, json1, json2 string) [
118
118
result = append (result , diff )
119
119
}
120
120
}
121
-
121
+
122
122
// Consolidate ALL array changes to whole array operations
123
123
for arrayPath , changes := range arrayChanges {
124
124
if len (changes ) > 0 {
125
125
// Get the complete arrays from both JSONs
126
126
oldArray := w .getValueAtPath (obj1 , arrayPath )
127
127
newArray := w .getValueAtPath (obj2 , arrayPath )
128
-
128
+
129
129
// Determine change type based on array existence
130
130
var changeType string
131
131
var fromValue , toValue * string
132
-
132
+
133
133
if oldArray == nil && newArray != nil {
134
134
changeType = "added"
135
135
toValue = w .formatPatchValue (newArray )
@@ -141,7 +141,7 @@ func (w *WI2LDiffer) postProcessArrays(diffs []DiffEntry, json1, json2 string) [
141
141
fromValue = w .formatPatchValue (oldArray )
142
142
toValue = w .formatPatchValue (newArray )
143
143
}
144
-
144
+
145
145
result = append (result , DiffEntry {
146
146
FullPath : arrayPath ,
147
147
FieldName : w .extractFieldNameFromPath (arrayPath ),
@@ -152,7 +152,7 @@ func (w *WI2LDiffer) postProcessArrays(diffs []DiffEntry, json1, json2 string) [
152
152
})
153
153
}
154
154
}
155
-
155
+
156
156
return result
157
157
}
158
158
@@ -275,4 +275,4 @@ func (w *WI2LDiffer) inferValueType(value interface{}) string {
275
275
default :
276
276
return "unknown"
277
277
}
278
- }
278
+ }
0 commit comments