diff --git a/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/JsonDeltaFormatter.cs b/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/JsonDeltaFormatter.cs index 6b24af7..f72334e 100644 --- a/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/JsonDeltaFormatter.cs +++ b/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/JsonDeltaFormatter.cs @@ -32,7 +32,7 @@ protected override void Format(DeltaType type, JsonFormatContext context, JToken break; case DeltaType.Deleted: - FormatDeleted(context); + FormatDeleted(context, delta); break; case DeltaType.Moved: @@ -71,17 +71,17 @@ private void FormatNode(JsonFormatContext context, JToken delta, JToken left) private void FormatAdded(JsonFormatContext context, JToken delta) { - context.PushCurrentOp(OperationTypes.Add, delta[0]); + context.PushCurrentOp(OperationTypes.Add, null, delta[0]); } private void FormatModified(JsonFormatContext context, JToken delta) { - context.PushCurrentOp(OperationTypes.Replace, delta[1]); + context.PushCurrentOp(OperationTypes.Replace, delta[0], delta[1]); } - private void FormatDeleted(JsonFormatContext context) + private void FormatDeleted(JsonFormatContext context, JToken delta) { - context.PushCurrentOp(OperationTypes.Remove); + context.PushCurrentOp(OperationTypes.Remove, delta[0]); } private void FormatMoved(JsonFormatContext context, JToken delta) diff --git a/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/JsonFormatContext.cs b/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/JsonFormatContext.cs index 362f5fc..0329644 100644 --- a/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/JsonFormatContext.cs +++ b/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/JsonFormatContext.cs @@ -22,12 +22,17 @@ public IList Result() public void PushCurrentOp(string op) { - Operations.Add(new Operation(op, CurrentPath(), null)); + Operations.Add(new Operation(op, CurrentPath(), null, null)); } - public void PushCurrentOp(string op, object value) + public void PushCurrentOp(string op, object from) { - Operations.Add(new Operation(op, CurrentPath(), null, value)); + Operations.Add(new Operation(op, CurrentPath(), from, null)); + } + + public void PushCurrentOp(string op, object from, object value) + { + Operations.Add(new Operation(op, CurrentPath(), from, value)); } public void PushMoveOp(string to) diff --git a/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/Operation.cs b/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/Operation.cs index 7901d35..32da10a 100644 --- a/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/Operation.cs +++ b/Src/JsonDiffPatchDotNet/Formatters/JsonPatch/Operation.cs @@ -13,7 +13,7 @@ public Operation(string op, string path, string from) From = from; } - public Operation(string op, string path, string from, object value) + public Operation(string op, string path, object from, object value) { Op = op; Path = path; @@ -28,7 +28,7 @@ public Operation(string op, string path, string from, object value) public string Op { get; set; } [JsonProperty("from")] - public string From { get; set; } + public object From { get; set; } [JsonProperty("value")] public object Value { get; set; }