faunadb-csharp icon indicating copy to clipboard operation
faunadb-csharp copied to clipboard

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

Open ikourfaln opened this issue 5 years ago • 2 comments

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.

ikourfaln avatar Oct 18 '20 17:10 ikourfaln

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

n400 avatar Apr 13 '21 22:04 n400

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.

goncalo-oliveira avatar Jul 01 '21 10:07 goncalo-oliveira