delivery-sdk-net
delivery-sdk-net copied to clipboard
Support System.Text.Json
Blockers
Deserialization of interface types is not supported.
- Polymorphic deserialization will be supported in .NET 5
- https://github.com/dotnet/runtime/issues/30083
Workaround
- https://github.com/lwardzala/Json.Abstraction
Motivation
- improve performance in high-throughput scenarios
- reduce the number of non-framework dependencies in the default implementation
- let users implement decide what deserializer to use
Proposed solution
- Use System.Text.Json for serialization
- Adjust code & docs so that it's clear how to implement a serializer of one's choice (some people might want to go e.g. with superfast Utf8Json)
Additional context
- How to migrate from Newtonsoft.Json to System.Text.Json
- improvements: https://devblogs.microsoft.com/dotnet/announcing-net-5-0-preview-3/
Benchmarks
- https://michaelscodingspot.com/the-battle-of-c-to-json-serializers-in-net-core-3/
- https://dotnetcoretutorials.com/2020/01/25/what-those-benchmarks-of-system-text-json-dont-mention/
- https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-apis/#user-content-performance
- https://github.com/dotnet/performance/tree/3b1f70c310b3f852d7084e3b10c76aa364573106/src/benchmarks/micro
- https://aloiskraus.wordpress.com/2019/09/29/net-serialization-benchmark-2019-roundup/
- https://medium.com/@samichkhachkhi/system-text-json-vs-newtonsoft-json-d01935068143
I found the extension library for System.Text.Json which supports interface deserialization - https://github.com/dahomey-technologies/Dahomey.Json
Some good news:
- https://devblogs.microsoft.com/dotnet/whats-next-for-system-text-json/
They plan to extend polymorphic serialization and deserialization: https://github.com/dotnet/runtime/issues/45189
So this feature might become unblocked after .NET 6.