System.Text.Json Rest Client
System.Text.Json Namespace Documentation
Newtonsoft has dominated the JSON serialization space for a long time. It is the most downloaded NuGet package around, but there are now alternatives. RestClient.Net implements the Microsoft .NET Core JSON Serializer belonging to the System.Text.Json namespace by default. A default serializer is a new feature for RestClient.Net because it does not depend on any 3rd party libraries.
Microsoft is now encouraging developers to use this serializer, but it’s essential to understand that it may not necessarily behave in the same way as Newtsonsoft. For example, Newtonsoft defaults to case insensitive properties. It makes it compatible with more backend services, but this impacts performance. My initial tests seem to show that System.Json.Text tends to be slower than Newtonsoft when properties are case insensitive. However, when case sensitivity is on, System.Json.Text seems to be faster than Newtonsoft. Full benchmarking of these two libraries is outside the scope of this library. But, I am doing some investigation to determine the fastest way to consume REST services.
Usage on .NET Core
var client = new Client(new Uri("https://restcountries.eu/rest/v2/")); var response = await client.GetAsync>();
There is full documentation about it here.
This is the default serialization adapter on .NET Core. Notice that the options can be changed by passing them into the constructor.
Please see the full documentation here. I’m hoping to hear about your experience with System.Text.Json. Are you experiencing issues with it? Are you experiencing performance degradation or improvement with it? Please check out the issues section on Github and let me know how it works for your project.