Starcounter-Jack / JSON-Patch

Lean and mean Javascript implementation of the JSON-Patch standard (RFC 6902). Update JSON documents using delta patches.
MIT License
1.79k stars 215 forks source link

Update to add old_value in the output #188

Closed JnBrewsterGT closed 7 years ago

JnBrewsterGT commented 7 years ago

I would really like to have the output not only have the value changed / added but also the old value.

JnBrewsterGT commented 7 years ago

Makes sense these tests would fail.

alshakero commented 7 years ago

Hey! I was just responding to your email!

Thanks for your interest. First, I'm sorry but we can't do exactly that because those operations follow an RFC standard and they can't have oldValue. You can see here. An operation can only have op, path and value. move and copy operations can have from. oldValue doesn't fit.

However

We have the same situation you're facing, and that's why we return OperationResults array! applyPatch function returns an array of all the old values that have been removed or replaced. You could use that instead.

Every operation returns an OperationResult object that has removed property set to the old value. You can find all the information here.

JnBrewsterGT commented 7 years ago

OK, makes sense. You can remove/close/reject this pr. Thanks.

JnBrewsterGT commented 7 years ago

Ok, thank you, I closed/denied the pr.

I appreciate you getting back to me so quickly.

John


John R. Brewster Research Scientist

Information and Communications Laboratory (ICL) Trusted Interoperable Systems & Architecture Division (TISAD) Systems Architecture & Development Operations Branch (SADO)

Georgia Tech Research Institute John.Brewster@GTRI.gatech.edu Office: 404.407.8452


From: Omar Alshaker notifications@github.com Sent: Thursday, July 27, 2017 3:49:43 AM To: Starcounter-Jack/JSON-Patch Cc: Brewster, John; Author Subject: Re: [Starcounter-Jack/JSON-Patch] Update to add old_value in the output (#188)

Hey! I was just responding to your email!

Thanks for your interest. First, I'm sorry but we can't do exactly that because those operations follow an RFC standard and they can't have oldValue. You can see here http://tools.ietf.org/html/rfc6902 . An operation can only have op, path and value. move and copy operations can have from. oldValue doesn't fit.

However

We have the same situation you're facing, and that's why we return results array! applyPatch function returns an array of all the old values that have been removed or replaced. You could use that instead.

Every operation returns an OperationResult object that has removed property set with the old value. You can find all the information here https://github.com/Starcounter-Jack/JSON-Patch#operationresult-type .

- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Starcounter-Jack/JSON-Patch/pull/188#issuecomment-318286620, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHGy9ScoNxvLNZscmfrFOkxOSq4w2q-cks5sSEEXgaJpZM4OknKz.