Bryan Martin
1 min readJul 12, 2021

--

Did you look at the link? A JSON patch payload is not the model. It's a collection of changes, each element has the following

1. the operation (required)

2. the path to child being changed in the model (required)

3. the new value (not required for remove)

Here is another link that is easier to read. (wikipedia)

https://en.wikipedia.org/wiki/JSON_Patch#:~:text=JSON%20Patch%20is%20a%20web,%2Fjson%2Dpatch%2Bjson%20.&text=Every%20object%20has%20two%20mandatory,op%22%20and%20%22path%22.

There is already a REST solution that is part of W3C standards for patches that solves the problem you're talking about. The ASP.NET already has a input formatter that corresponds to the application/json-patch+json content-type.

https://docs.microsoft.com/en-us/aspnet/core/web-api/jsonpatch?view=aspnetcore-5.0

This formatter will take a JSON patch payload and deserialize it into a JsonPatchDocument<TModel> type argument in the controller action. This can be used to apply changes to an existing entity loaded from the database. This solution is much less chatty than creating an endpoint to update every property on an entity. So, the point I'm making is a direct contradiction to what you are saying.

--

--

No responses yet