Skip to content

Fix example, to should be path #11

Description

@bradyt

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}}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions