Skip to content

Support for JSON Merge Patch (RFC 7386) #35237

@Tiberriver256

Description

@Tiberriver256

Is your feature request related to a problem? Please describe.

Implementing JSON Merge Patch manually can be quite tricky but provides a simpler experience for API consumers.

Describe the solution you'd like

Currently there is built-in support for JSON Patch (RFC 6902) via JsonPatchDocument. Would love to also see an implementation of RFC 7386.

So no one has to wade through an RFC...

Given the following JSON representation:

{
  "name": "Joe",
  "email": "joe@example.com",
  "physicalAttributes": { "weight": 75, "height": 175 },
  "favoriteColors": ["blue", "red"]
}

These two will produce equivalent modifications:

JSON Patch

[
   { "op": "remove", "path": "/email" },
   { "op": "add", "path": "/favoriteColors/-", "value": "black" }
]

JSON Merge Patch

{
  "email": null,
  "favoriteColors": ["blue", "red", "black"]
}

Additional context

OData has an implementation of this spec via Delta but it was not designed to work with formatters other than OData.

Here are a couple of open-source implementations:
https://www.strathweb.com/2013/01/easy-asp-net-web-api-resource-updates-with-delta/
https://github.com/Morcatko/Morcatko.AspNetCore.JsonMergePatch

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-json-patch

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions