Skip to content
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

Set the property to look for in JsonDerivedType #97067

Closed
vsfeedback opened this issue Jan 17, 2024 · 2 comments
Closed

Set the property to look for in JsonDerivedType #97067

vsfeedback opened this issue Jan 17, 2024 · 2 comments

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


.NET 7 provide polymophic deserialisation. Works fine but the way it is implemented has some drawbacks.

  1. it only looks for the $Type property in a json object
  2. $Type must be the first property in a json object

change requests

  • rename typeDiscriminator to typeDiscriminatorValue
  • add typeDiscriminatorName = the name of the property to look for and match its value with the typeDiscriminatorValue
  • do not require the typediscriminator property to be the first property in the json

Original Comments

Feedback Bot on 6/20/2023, 08:31 PM:

(private comment, text removed)

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 17, 2024
@ghost
Copy link

ghost commented Jan 17, 2024

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

This issue has been moved from a ticket on Developer Community.


.NET 7 provide polymophic deserialisation. Works fine but the way it is implemented has some drawbacks.

  1. it only looks for the $Type property in a json object
  2. $Type must be the first property in a json object

change requests

  • rename typeDiscriminator to typeDiscriminatorValue
  • add typeDiscriminatorName = the name of the property to look for and match its value with the typeDiscriminatorValue
  • do not require the typediscriminator property to be the first property in the json

Original Comments

Feedback Bot on 6/20/2023, 08:31 PM:

(private comment, text removed)

Author: vsfeedback
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@eiriktsarpalis
Copy link
Member

it only looks for the $Type property in a json object

The actual name of type discriminator property can be configured using the JsonPolymorphic attribute.

$Type must be the first property in a json object

This is tracked by #72604. We expect a fix to make its way in .NET 9.

rename typeDiscriminator to typeDiscriminatorValue

Renaming APIs that have already shipped is a breaking change that we couldn't consider, unfortunately.

Hope this answers your questions.

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jan 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants