-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Adding support for custom JsonConverter(s) when deserializing JSON Patch value object #30974
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
Conversation
…kes an IContractResolver and hooking it up for ListAdapter - Unit test to verify above works for heterogenous collections
…viderUsesContractResolver Andremi/conversion result provider uses contract resolver
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you feel about this? It avoids an additional public API
src/Features/JsonPatch/src/Internal/ConversionResultProvider.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Pranav K <[email protected]>
Co-authored-by: Pranav K <[email protected]>
PR Title
Adding support for custom JsonConverter(s) when deserializing JSON Patch value object
PR Description
When we started using the JSON Patch library we hit an issue with heterogenous collections. To specify what type an object in a heterogenous collection is, we added a "Type" property to the JSON value object. However, regardless of what we supplied in our custom ContractResolver, nothing was getting used when the JObject was converted to a concrete object.
Once we looked at the sources we found out that the JsonPatchDocument.ContractResolver is not used at all when deserializing the value object. So we added an overload that takes an IContractResolver and wired it up for the ListAdapter.
That solved our issue as now our custom JsonConverter is used to read the "Type" property and create the correct object instance. We also added an integration unit test that covers this scenario.