.NET 5 brings interesting new features. In this article I will introduce you a new namespace that provides many extension methods for HttpClient and HttpContent that perform serialization and deserialization using System.Text.Json: Here is System.Net.Http.Json !

The content of this article is taken from Microsoft’s documentation, + my content (samples) in addition.

There are three classes in that namespace:

  • HttpClientJsonExtensions which provides extension methods to send/receive HTTP content as JSON
  • HttpContentJsonExtensions which provides extension methods to read and then parse the HttpContent from JSON
  • JsonContent which provides HTTP content based on JSON

Let’s take a look at some pieces of code together to see how it works, but before we’ll need to download the following required package:

#.net 5 #aspdotnet #web-development

.NET 5: Exploring System.Net.Http.Json namespace
4.90 GEEK