Skip to content

System.Text.Json AOT Polymorphic serialization #115303

Discussion options

You must be logged in to vote

In the context of AOT, apart from declaring a derived type you also need to tell the serializer how that derived type is meant to be serialized. This involves having the user define their own context for DerivedType and pass that into JsonSerializerOptions as well. In your example, this would involve having the Register<T>() method additionally accept a JsonSerializerContext argument which is then appended to the TypeInfoResolverChain property in your JsonSerializerOptions.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@markdibarry
Comment options

Answer selected by markdibarry
Comment options

You must be logged in to vote
1 reply
@markdibarry
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Text.Json untriaged New issue has not been triaged by the area owner
3 participants
Converted from issue

This discussion was converted from issue #115273 on May 05, 2025 14:37.