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

Add a merge operator #31

Open
tyronx opened this issue Aug 26, 2022 · 0 comments
Open

Add a merge operator #31

tyronx opened this issue Aug 26, 2022 · 0 comments

Comments

@tyronx
Copy link

tyronx commented Aug 26, 2022

The current RFC lacks compatibility when using multiple json patches, most glaringly the inability to patch patched json - for patches that are made by independent authors and thus are not aware of the others patches. Take the following initial situation:

Source file

{ "firstname": "Mad", "lastname": "Max" }

Patch 1

{ "op": "add", "path": "/attributes", "value": { "age": 15 } }

Patch 2

{ "op": "add", "path": "/attributes", "value": { "continent": "Europe" } }

As per RFC6902, the add op replaces the value if it exists, and thus we get

{ "firstname": "Mad", "lastname": "Max", "attributes": { "continent": "Europe" } }

which means we have lost the age property. I propose a merge op that merges the value if it is an object.

@tyronx tyronx changed the title merge operator Add a merge operator Aug 26, 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