aspnetcore
aspnetcore copied to clipboard
Support for JSON Merge Patch (RFC 7386)
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<T> 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
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.
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).