Questions about using AddNewtonsoftKinson during custom converter usage in .net6
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Questions-about-using-AddNewtonsoftKinso/10488437)._
---
[severity:Other]
Version: .net6
Issue: Added an issue in the program where the custom converter for System.Text.Json.Serialization that registered AddNewtonsoftJson and then wrote in the code did not take effect.
Looking for the official instructions, I saw the following:
1. AddNewtonsoftJson replaces the default input and output formatter based on System.Text.Json, which is used to format all JSON content.

2. Based on the first point, NewtonsoftJson is equivalent to replacing System.Text.JSON as a built-in converter, so I should observe the following when using it: only if the applicable custom converter is not registered, the built-in converter will be selected.

3. Based on the second point, I used a custom converter that inherits System.Text.JSON in my code, and registered with the property with the highest priority, then the custom converter should have the highest priority and should take effect. But the truth is that it didn't work.

In summary: The current understanding is that when AddNewtonsoftJson is not used, the priority is according to the official given, the attribute registration is the highest, and it is effective. When using AddNewtonsoftJson, the official System.Text.JSON is set by NewtonsoftJson by default, System.Text.JSON is not effective. Doubt: According to the official priority and the instructions in the second point above, if I customize the converter and register it according to the highest priority attribute, whether or not I use AddNewtonsoftJson, it should actually take effect. We should follow the principle of priority, otherwise, once I use AddNewtonsoftJson, I can't use System.Text.Json's custom converter?
---
### Original Comments
#### Feedback Bot on 10/11/2023, 00:47 AM:
(private comment, text removed)
#### Feedback Bot on 10/11/2023, 02:46 AM:
(private comment, text removed)
---
### Original Solutions
(no solutions)
Contributor guide
Assessment
This issue has not been assessed yet.