jsondiffpatch.net icon indicating copy to clipboard operation
jsondiffpatch.net copied to clipboard

Add optional old value in replace operation

Open mariotoffia opened this issue 1 year ago • 0 comments

Hi @wbish,

When OperationTypes.Replace it will capture the replace value and add it to the operation. The old property is only JSON visible when not null. Hence, the following output can be achieved:

The diff:

{"building":{"loc":{"provision":["2023-12-18T15:08:26Z","2024-02-01T16:00:00Z"]}}}

The json delta formatter:

[{"path":"/building/loc/provision","op":"replace","value":"2024-02-01T16:00:00Z","old":"2023-12-18T15:08:26Z"}]

I'm on a Mac and do not have mono, so sorry for not providing any unit test - I've used it in my other project code and it seems to work properly.

I hope, this is a valid contribution. Please tell me otherwise and I'll fix it.

Cheers, Mario :)

mariotoffia avatar Feb 12 '24 07:02 mariotoffia