weichch / system-text-json-jsondiffpatch

High-performance, low-allocating JSON object diff and patch extension for System.Text.Json. Support generating patch document in RFC 6902 JSON Patch format.
MIT License
102 stars 13 forks source link

Get the differences from one side instead of both? #34

Closed Pikachews closed 1 year ago

Pikachews commented 1 year ago

Is there a way to get the different between left and right but only returning the field of one side? e.g.

A = {
    changedField: "value1",
    unchangedField: "test"
}

B = {
    changedField: "value2",
    unchangedField: "test"
}

A.Diff(B) = {
    changedField: "value2"
}
weichch commented 1 year ago

By default the diff is generated in jsondiffpatch format which has both old and new values when property value changes.

You can implement your own formatter to convert the default delta into any format. One built-in example is JsonPatchDeltaFormatter.