algoliasearch-client-csharp
algoliasearch-client-csharp copied to clipboard
discussion: Consider replacing Newtonsoft JSON with the new std Serializer
.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.
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 ofSystem.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
andSystem.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 toSystem.Text.Json
attributes. (like for theobjectID
) it’s a soft BC. - Major version without big additions to the public AP or new features.
WDYT @aseure @nunomaduro @maxiloc @chloelbn ?
That's seems really reasonable to me and a very good move towards:
- a state-of-the-art .NET library by using this soon-to-be widely adopted JSON serializer
- 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.
Closing this issue as we just released a new version of the client (7.0). This client now use System.Text.Json
.