Before:
dart example/main.dart
Diff algorithm found changes: [{op: replace, path: /test, value: 6}, {op: replace, path: /object/list/2, value: 4}, {op: replace, path: /object/child, value: 5}]
Unhandled exception:
Patch field "path" is missing.
#0 JsonPatch._extractPath (package:json_patch/src/json_patch.dart:304:7)
#1 JsonPatch._applyOne (package:json_patch/src/json_patch.dart:279:20)
#2 JsonPatch.apply (package:json_patch/src/json_patch.dart:223:16)
#3 main (file:///private/tmp/dart-json-patch/example/main.dart:23:31)
#4 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
Fix:
modified example/main.dart
@@ -31,7 +31,7 @@ void main() {
'path': '/test',
'value': {'child': 'value'}
},
- {'op': 'move', 'from': '/test', 'to': '/moved'},
+ {'op': 'move', 'from': '/test', 'path': '/moved'},
],
strict: true,
);
After:
dart example/main.dart
Diff algorithm found changes: [{op: replace, path: /test, value: 6}, {op: replace, path: /object/list/2, value: 4}, {op: replace, path: /object/child, value: 5}]
Object after applying patch operations: {a: 5, moved: {child: value}}
Before:
Fix:
After: