rfc_6902 0.2.0 copy "rfc_6902: ^0.2.0" to clipboard
rfc_6902: ^0.2.0 copied to clipboard

JSON Patch (RFC 6902). Implements Add, Copy, Move, Remove, Replace, Test operations on JSON documents using JSON Pointers.

example/example.dart

import 'dart:convert';

import 'package:rfc_6902/rfc_6902.dart';

void main() {
  const document = {
    'a': {
      'b': {'c': 'foo'}
    }
  };
  const json = '''
   [
     { "op": "test", "path": "/a/b/c", "value": "foo" },
     { "op": "remove", "path": "/a/b/c" },
     { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
     { "op": "replace", "path": "/a/b/c", "value": 42 },
     { "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
     { "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }
   ]
  ''';
  final patch = JsonPatch(jsonDecode(json));
  final result = patch.applyTo(document);
  print(result); // {a: {b: {d: 42, e: 42}}}
}
6
likes
160
points
1.49k
downloads

Publisher

verified publisherkarapetov.com

Weekly Downloads

JSON Patch (RFC 6902). Implements Add, Copy, Move, Remove, Replace, Test operations on JSON documents using JSON Pointers.

Repository (GitHub)
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

rfc_6901

More

Packages that depend on rfc_6902