json-patch ~master
RFC 6902 JSON Patch implementation
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
JavaScript Object Notation (JSON) Patch
This is implementation of rfc6902.
JSON Patch defines a JSON document structure for expressing a sequence of operations to apply to a JavaScript Object Notation (JSON) document.
library functionality:
- generate diff between two documents
- patch in place document using generated patch
Json document format accepted: JSONValue
Interface
alias JsonItem = JSONValue;
// diff part
DiffOperation[] diff(const ref JsonItem source, const ref JsonItem target,
const string path = "");
JsonItem toJson(DiffOperation[] d);
// patch part
bool patchInPlace(ref JsonItem document, ref const JsonItem patch);
Usage
import vision.json.patch.commons;
import vision.json.patch.diff;
import vision.json.patch.patch;
JsonItem source = ...;
JsonItem target = ...;
auto patch = diff(source, target).toJson;
auto patched = source;
patched.patchInPlace(patch);
assert(patched == target)
- ~master released 6 years ago
- crimaniak/json-patch
- BSL-1.0
- Copyright © 2018, Alexey Kulentsov
- Authors:
- Dependencies:
- json-pointer
- Versions:
-
0.0.1 2018-Jun-02 ~master 2018-Jun-02 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
9 downloads total
-
- Score:
- 0.5
- Short URL:
- json-patch.dub.pm