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

Could we add oldvalue to the JSON patch standard? #30

Open
mmachenry opened this issue Aug 10, 2022 · 0 comments
Open

Could we add oldvalue to the JSON patch standard? #30

mmachenry opened this issue Aug 10, 2022 · 0 comments

Comments

@mmachenry
Copy link

I believe the addition of an oldvalue field to the replace and remove operations for JSON patch could greatly increase the usability and adoption because with this simple change it allows JSON patch to act as both an edit history as well as enables patches to be reverted instead of only applied.

I'm using JSON patch for documenting user updates to objects in my database. This is a DynamoDB accessible through a REST API so JSON Patch is a pretty natural standard for this. I store every patch along with the current version and users can see the edit history which I display to the web app front end.

I do, however, in my application need to extend the patch standard with one extra feature, which is the old value of any remove or replace operation. This gives me the two aforementioned features that I need.

For starters, the user can now see, when I expose the JSON patch data to the the front end, what the edit history is. Without the oldvalue a user only knows what a new value has become and not what it used to be. Adding old value now gives the whole picture of the edit, which is necessary when creating a user edit history for a database JSON document.

Next, I would like to be able to take my edit history along with the current value in the DB and revert the changes of an edit. In order to do this we need to understand what the old value is to reverse the process but adding this to just replace and remove gives us just that.

I'm wondering if there's any chance you'd be interested in augmenting the existing standard in this way.

Thank you very much for the consideration and great work on the existing standard.

@mnot mnot transferred this issue from json-patch/json-patch-tests Aug 12, 2022
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

No branches or pull requests

1 participant