consider adding TypeNameHandling.All to the Json serialization settings
See original GitHub issueI have a WebJob triggering from a queue message and the message argument is set as an abstract base type. As a result I get an exception saying that I could use a string and handle the serialization myself.
If the serialization settings for both serialize and deserialize had the TypeNameHandling set to All, then I believe the derived objects would be serialized correctly:
new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }
Thank you, Paulo
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
TypeNameHandling setting
This sample uses the TypeNameHandling setting to include type information when serializing JSON and read type information so that the create types are...
Read more >c# - is Newtonsoft TypeNameHandling.all with a basic ...
1 Answer 1 ... Which can be used as follows: var settings = new JsonSerializerSettings { SerializationBinder = new MySerializationBinder(), ...
Read more >CA2326: Do not use TypeNameHandling values other than ...
This rule finds Newtonsoft.Json.TypeNameHandling values other than None . If you want to deserialize only when a Newtonsoft.Json.Serialization.
Read more >Json.NET Serializer • Newtonsoft Serializer
A JSON serializer that uses Newtonsoft Json.NET. ... This feature requires the TypeNameHandling setting to be set to Auto or All .
Read more >Adding $type to System.Text.Json Serialization like in ...
This article describes a technique to serialize models containing dynamic types with System.Text.Json JsonSerializer, that doesn't support ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We could probably expose a hook for the serializer settings to be changed.
@HMoen I haven’t looked at this in a while but I think the only way to get around it is to create several messages for the different derived types (instead of a single one for the base type).