delivery-sdk-net icon indicating copy to clipboard operation
delivery-sdk-net copied to clipboard

Support System.Text.Json

Open petrsvihlik opened this issue 4 years ago • 2 comments

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

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

petrsvihlik avatar May 03 '20 14:05 petrsvihlik

I found the extension library for System.Text.Json which supports interface deserialization - https://github.com/dahomey-technologies/Dahomey.Json

tomasjurasek avatar Aug 26 '20 05:08 tomasjurasek

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.

petrsvihlik avatar Jan 15 '21 07:01 petrsvihlik