Skip to content

Support for JSON Merge Patch (RFC 7386) #35237

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

Open
Tiberriver256 opened this issue Aug 10, 2021 · 3 comments
Open

Support for JSON Merge Patch (RFC 7386) #35237

Tiberriver256 opened this issue Aug 10, 2021 · 3 comments
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-json-patch
Milestone

Comments

@Tiberriver256
Copy link

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": "[email protected]",
  "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

@mkArtakMSFT mkArtakMSFT added old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels feature-json-patch labels Aug 10, 2021
@rafikiassumani-msft rafikiassumani-msft added this to the Backlog milestone Sep 1, 2021
@ghost
Copy link

ghost commented Sep 1, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@amcasey amcasey added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Jun 2, 2023
@captainsafia captainsafia added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Jun 20, 2023
@mitsha-microsoft
Copy link

Hi,
Our service uses PATCH primarily for a huge set of our APIs and having something built-in that handles RFC 7386 will help us greatly (otherwise we will need to roll out our own implementation or use a third party OSS package).

@desjoerd
Copy link

@mikekistler I totally agree that this is the more friendly patch method like you mentioned in the .NET 10 Preview4 unboxed!.

I currently use my "own" wrapper value to be able to do this https://github.com/desjoerd/OptionalValues. But having native support for this would be awesome.

I also have an horrible implementation which runs on json level... https://github.com/desjoerd/toolbox/tree/main/dotnet/Toolbox/JsonMerge

Is adding this something which is open for help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-json-patch
Projects
None yet
Development

No branches or pull requests

7 participants