-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Polymorphic Serialization - Doesn't allow typeDiscriminator to be anything but first #73693
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionI have this endpoint:
and my BaseClass is annotated as follows:
When sending a json body where
Reproduction StepsSending this as a POST request throws the error:
however this doesn't:
{
Expected behaviorI understand the performance advantages to having the discriminator as the first property however is there a toggle/option that can be set to allow the JsonSerializer to look through the whole jsonObject first for the discriminator? Actual behavior.... Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
FYI - Using .Net 7 Preview 7 |
See #72604 |
Duplicate of #72604. |
Description
I have this endpoint:
and my BaseClass is annotated as follows:
When sending a json body where
resourceType
is anything but the first property, I get the following error:Reproduction Steps
Sending this as a POST request throws the error:
however this doesn't:
{
"resourceType": "DerivedClass1",
"prop1": 1,
"prop2": "test",
}
Expected behavior
I understand the performance advantages to having the discriminator as the first property however is there a toggle/option that can be set to allow the JsonSerializer to look through the whole jsonObject first for the discriminator?
Actual behavior
....
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: