Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of JSON RFC 6902 #36

Merged
merged 4 commits into from
Mar 31, 2020
Merged

Implementation of JSON RFC 6902 #36

merged 4 commits into from
Mar 31, 2020

Conversation

justinbhopper
Copy link
Contributor

@justinbhopper justinbhopper commented Mar 30, 2020

Implementation of a formatter that converts a json delta object into patch operations, according to JSON RFC 6902. https://tools.ietf.org/html/rfc6902

This is a port of the JSON formatter in the original jsondiffpatch. Like the original, it does not support TextDiffMode.Efficient, due to the fact that we are converting the delta into the JSON RFC 6902 spec and thus cannot distinguish between a text-diff and full-text operation.

I have also added unit tests.

Example usage:

var left = JObject.Parse("{ \"name\": \"Justin\" }");
var right = JObject.Parse("{ \"name\" : \"John\", \"age\": 34 }");
var patch = new JsonDiffPatch().Diff(left, right);
var formatter = new JsonDeltaFormatter();
var operations = formatter.Format(patch);

/*
operations: [
  { "op": "replace", "path": "/name", "value": "John" },
  { "op": "add", "path": "/age", "value": 34 }
]
*/

cc: @wbish

@wbish wbish merged commit dbc1993 into wbish:master Mar 31, 2020
@wbish
Copy link
Owner

wbish commented Mar 31, 2020

Thanks for working on this @justinbhopper. I've released 2.2.0 so folks can start using this since its been requested for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants