This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This gist uses a custom JsonConverter to support derived types in ASP.NET Core 3 requests and responses. By default, .NET Core | |
does not support derived types in JSON serialization; the properties of derived types are not serialized in responses, and in | |
requests there is inherently a lack of support in JSON for identifying inherited types. | |
More info: https://stackoverflow.com/questions/59308763/derived-types-properties-missing-in-json-response-from-asp-net-core-api | |
To implement this code in your project: | |
1. Copy the DerivedTypeJsonConverter class below into your project. | |
2. For each of your base types, create a class that derives from DerivedTypeJsonConverter. Follow the MyResultJsonConverter | |
example below. |