fauna / faunadb-csharp

C# driver for FaunaDB v4
https://fauna.com
Other
62 stars 15 forks source link

use System.Text.Json instead of Newtonsoft.Json ! #124

Open ikourfaln opened 3 years ago

ikourfaln commented 3 years ago

Hi,

Regarding JSON serializer, I see that FaunaDB.Client is using Newtonsoft.Json !! Check out the System.Text.Json package, I highly recommend using it, it is Fast plus it's owned and maintained by Microsoft.

Starting ASP.NET Core 3.1, System.Text.Json is the default JSON Serializer, and Newtonsoft.Json will be removed starting .NET 5.

n400 commented 3 years ago

Thank you for this suggestion. We are working this into our roadmap, being tracked internally as DRV-531

goncalo-oliveira commented 3 years ago

Actually, it might be best if this is optional. You could use System.Text.Json by default, but you should allow to configure Newtonsoft.Json as an alternative. Microsoft's serializer has some issues, such as not supporting polymorphic deserialization (and limited serialization).

polymorphic serialization polymorphic deserialization

Also... this comment is not exactly accurate

and Newtonsoft.Json will be removed starting .NET 5.

While Microsoft's serializer is the default (for obvious reasons), one can still use Newtonsoft.Json on ASP.NET projects. You just need to include the package Microsoft.AspNetCore.Mvc.NewtonsoftJson and when setting up the controllers on startup do this

services.AddControllers().AddNewtonsoftJson();

So... Newtonsoft's serializer isn't going anywhere just yet and much less while the polymorphic serialization issues prevail. And since that was a design decision, even less.