mapping a dynamic object to an existing object and only map properties that exist in the source obj
I need help with patching an object in ASP Core, on my api i only send a partial data of the object i want to update, i looked into
JsonPatchDocument<T>
but the syntax is too complicated compared to what my competitors do with their API, what i want here is just for my customers to send a json with the properties and values they want to change and that's it, let's say i have an object like
and in my API I only want to update specific properties, so I decided to take a dynamic object in my action
in my update method i have this code
now, for some reason existingCar
has all properties turned to their default or null values, how should i fix this? is there an alternative library for doing this2 Replies
If the purpose is dynamicly changing values, it is better to use
JsonPatchDocument<T>
here is guideline https://learn.microsoft.com/en-us/aspnet/core/web-api/jsonpatch?view=aspnetcore-8.0JsonPatch in ASP.NET Core web API
Learn how to handle JSON Patch requests in an ASP.NET Core web API.
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View