algoliasearch-client-csharp icon indicating copy to clipboard operation
algoliasearch-client-csharp copied to clipboard

discussion: Consider replacing Newtonsoft JSON with the new std Serializer

Open Ant-hem opened this issue 5 years ago • 2 comments

.NET hasn't had a (great) built-in way to deal with JSON. Instead we've relied on Json.NET which continues to serve the .NET ecosystem well.

.NET Core 3 will be shipped with a brand new (and performant) JSON Serializer. Let's consider using it in the library.

Ant-hem avatar Sep 16 '19 08:09 Ant-hem

After digging more into the subject I found a balanced strategy we could consider to implement System.Text.Json (the new standard library) instead of Newtonsoft.JSON (the dependency we have for the current Serializer)

Good to know is that System.Text.Json is supporting .NET 461 & .NET Standard 2.0. (See the dependency on Nuget)

What we could do:

  • Drop the support for .NET45 & .NET Standard 1.3
  • Drop Newtonsoft.JSON in favor of System.Text.Json
  • Bump the library to a new major version

What are the benefits of this solution?

  • No pre-processor in the code to support both Newtonsoft.JSON and System.Text.Json
  • Library without dependency
  • Library up to the latest standard
  • No BC on the public API

What are the cons of this solution?

  • We are dropping out .NET45 user - but the update from .NET45 to .NET461 is without BC
  • If some of our users where using NewtonSoft attributes in their POCOs they would need to update to System.Text.Json attributes. (like for the objectID) it’s a soft BC.
  • Major version without big additions to the public AP or new features.

WDYT @aseure @nunomaduro @maxiloc @chloelbn ?

Ant-hem avatar Sep 26 '19 16:09 Ant-hem

That's seems really reasonable to me and a very good move towards:

  1. a state-of-the-art .NET library by using this soon-to-be widely adopted JSON serializer
  2. a dependency-free library which is a huge win for the users (no conflicts) and for us the maintainers (less time spent trying to reproduce user-code environment for debugging purpose)

@Ant-hem I've flagged this issue with a newly created label Next Major to keep track of those kind of changes we may want to keep in mind in future major versions.

aseure avatar Sep 27 '19 08:09 aseure

Closing this issue as we just released a new version of the client (7.0). This client now use System.Text.Json.

morganleroi avatar Feb 21 '24 10:02 morganleroi