System.Net.Http.Json
8.0.0
dotnet add package System.Net.Http.Json --version 8.0.0
NuGet\Install-Package System.Net.Http.Json -Version 8.0.0
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
paket add System.Net.Http.Json --version 8.0.0
#r "nuget: System.Net.Http.Json, 8.0.0"
// Install System.Net.Http.Json as a Cake Addin
#addin nuget:?package=System.Net.Http.Json&version=8.0.0
// Install System.Net.Http.Json as a Cake Tool
#tool nuget:?package=System.Net.Http.Json&version=8.0.0
About
Provides extension methods for System.Net.Http.HttpClient
and System.Net.Http.HttpContent
that facilitate serialization and deserialization of HTTP requests using System.Text.Json.
Key Features
- Extension methods for deserializing HTTP response JSON bodies.
- Extension methods for serializing HTTP request JSON bodies.
- Extension methods for deserializing JSON from
HttpContent
instances.
How to Use
using System.Net.Http.Json;
using var client = new HttpClient();
// Get the list of all books
Book[] books = await client.GetFromJsonAsync<Book[]>("https://api.contoso.com/books");
// Send a POST request to add a new book
var book = new Book(id: 42, "Title", "Author", publishedYear: 2023);
HttpResponseMessage response = await client.PostAsJsonAsync($"https://api.contoso.com/books/{book.id}", book);
if (response.IsSuccessStatusCode)
Console.WriteLine("Book added successfully.");
else
Console.WriteLine($"HTTP request failed with status code: {response.StatusCode}");
public record Book(int id, string title, string author, int publishedYear);
Main Types
The main types provided by this library are:
HttpClientJsonExtensions
HttpContentJsonExtensions
Additional Documentation
Related Packages
Feedback & Contributing
System.Net.Http.Json is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.Text.Json (>= 8.0.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETStandard 2.0
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- System.Text.Json (>= 8.0.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
net6.0
- System.Text.Json (>= 8.0.0)
-
net7.0
- System.Text.Json (>= 8.0.0)
-
net8.0
- System.Text.Json (>= 8.0.0)
NuGet packages (547)
Showing the top 5 NuGet packages that depend on System.Net.Http.Json:
Package | Downloads |
---|---|
Refit
The automatic type-safe REST library for Xamarin and .NET |
|
Dapr.Client
This package contains the reference assemblies for developing services using Dapr. |
|
OpenIddict.Validation.SystemNetHttp
System.Net.Http integration package for the OpenIddict validation services. |
|
StrawberryShake.Transport.Http
GraphQL over HTTP transport implementation for StrawberryShake GraphQL clients. |
|
Steeltoe.Extensions.Configuration.ConfigServerBase
Configuration provider for reading from Spring Cloud Config Server |
GitHub repositories (178)
Showing the top 5 popular GitHub repositories that depend on System.Net.Http.Json:
Repository | Stars |
---|---|
dotnet/runtime
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
|
|
dotnet-architecture/eShopOnWeb
Sample ASP.NET Core 7.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
|
|
restsharp/RestSharp
Simple REST and HTTP API Client for .NET
|
|
reactiveui/refit
The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
|
|
MudBlazor/MudBlazor
Blazor Component Library based on Material design with an emphasis on ease of use. Mainly written in C# with Javascript kept to a bare minimum it empowers .NET developers to easily debug it if needed.
|