Skip to content

Add a merge operator #31

Open
Open
@tyronx

Description

@tyronx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions