HttpClientJsonExtensions.GetFromJsonAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetFromJsonAsync(HttpClient, Uri, Type, JsonSerializerOptions, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync(HttpClient, String, Type, JsonSerializerContext, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync(HttpClient, Uri, Type, JsonSerializerContext, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync(HttpClient, Uri, Type, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync(HttpClient, String, Type, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync(HttpClient, String, Type, JsonSerializerOptions, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync<TValue>(HttpClient, Uri, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync<TValue>(HttpClient, String, JsonSerializerOptions, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync<TValue>(HttpClient, String, JsonTypeInfo<TValue>, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync<TValue>(HttpClient, Uri, JsonSerializerOptions, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync<TValue>(HttpClient, Uri, JsonTypeInfo<TValue>, CancellationToken) |
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation. |
GetFromJsonAsync(HttpClient, Uri, Type, JsonSerializerOptions, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync (this System.Net.Http.HttpClient client, Uri? requestUri, Type type, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * Uri * Type * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>
<Extension()>
Public Function GetFromJsonAsync (client As HttpClient, requestUri As Uri, type As Type, options As JsonSerializerOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Object)
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- Uri
The Uri the request is sent to.
- type
- Type
The type of the object to deserialize to and return.
- options
- JsonSerializerOptions
Options to control the behavior during deserialization. The default options are those specified by Web.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Applies to
GetFromJsonAsync(HttpClient, String, Type, JsonSerializerContext, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync (this System.Net.Http.HttpClient client, string? requestUri, Type type, System.Text.Json.Serialization.JsonSerializerContext context, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * string * Type * System.Text.Json.Serialization.JsonSerializerContext * System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>
<Extension()>
Public Function GetFromJsonAsync (client As HttpClient, requestUri As String, type As Type, context As JsonSerializerContext, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Object)
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- String
The Uri the request is sent to.
- type
- Type
The type of the object to deserialize to and return.
- context
- JsonSerializerContext
The JsonSerializerContext used to control the deserialization behavior.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Applies to
GetFromJsonAsync(HttpClient, Uri, Type, JsonSerializerContext, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync (this System.Net.Http.HttpClient client, Uri? requestUri, Type type, System.Text.Json.Serialization.JsonSerializerContext context, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * Uri * Type * System.Text.Json.Serialization.JsonSerializerContext * System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>
<Extension()>
Public Function GetFromJsonAsync (client As HttpClient, requestUri As Uri, type As Type, context As JsonSerializerContext, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Object)
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- Uri
The Uri the request is sent to.
- type
- Type
The type of the object to deserialize to and return.
- context
- JsonSerializerContext
The JsonSerializerContext used to control the deserialization behavior.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Applies to
GetFromJsonAsync(HttpClient, Uri, Type, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync (this System.Net.Http.HttpClient client, Uri? requestUri, Type type, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * Uri * Type * System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>
<Extension()>
Public Function GetFromJsonAsync (client As HttpClient, requestUri As Uri, type As Type, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Object)
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- Uri
The Uri the request is sent to.
- type
- Type
The type of the object to deserialize to and return.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Remarks
This method uses JsonSerializerDefaults.Web options for deserialization, whereas JsonSerializer deserialization methods do not, by default.
Applies to
GetFromJsonAsync(HttpClient, String, Type, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync (this System.Net.Http.HttpClient client, string? requestUri, Type type, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * string * Type * System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>
<Extension()>
Public Function GetFromJsonAsync (client As HttpClient, requestUri As String, type As Type, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Object)
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- String
The Uri the request is sent to.
- type
- Type
The type of the object to deserialize to and return.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Remarks
This method uses JsonSerializerDefaults.Web options for deserialization, whereas JsonSerializer deserialization methods do not, by default.
Applies to
GetFromJsonAsync(HttpClient, String, Type, JsonSerializerOptions, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync (this System.Net.Http.HttpClient client, string? requestUri, Type type, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * string * Type * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>
<Extension()>
Public Function GetFromJsonAsync (client As HttpClient, requestUri As String, type As Type, options As JsonSerializerOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Object)
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- String
The Uri the request is sent to.
- type
- Type
The type of the object to deserialize to and return.
- options
- JsonSerializerOptions
Options to control the behavior during deserialization. The default options are those specified by Web.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Applies to
GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue> (this System.Net.Http.HttpClient client, string? requestUri, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Value>
<Extension()>
Public Function GetFromJsonAsync(Of TValue) (client As HttpClient, requestUri As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TValue)
Type Parameters
- TValue
The target type to deserialize to.
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- String
The Uri the request is sent to.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Remarks
This method uses JsonSerializerDefaults.Web options for deserialization, whereas JsonSerializer deserialization methods do not, by default.
Applies to
GetFromJsonAsync<TValue>(HttpClient, Uri, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue> (this System.Net.Http.HttpClient client, Uri? requestUri, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * Uri * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Value>
<Extension()>
Public Function GetFromJsonAsync(Of TValue) (client As HttpClient, requestUri As Uri, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TValue)
Type Parameters
- TValue
The target type to deserialize to.
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- Uri
The Uri the request is sent to.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Remarks
This method uses JsonSerializerDefaults.Web options for deserialization, whereas JsonSerializer deserialization methods do not, by default.
Applies to
GetFromJsonAsync<TValue>(HttpClient, String, JsonSerializerOptions, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue> (this System.Net.Http.HttpClient client, string? requestUri, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * string * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Value>
<Extension()>
Public Function GetFromJsonAsync(Of TValue) (client As HttpClient, requestUri As String, options As JsonSerializerOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TValue)
Type Parameters
- TValue
The target type to deserialize to.
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- String
The Uri the request is sent to.
- options
- JsonSerializerOptions
Options to control the behavior during deserialization. The default options are those specified by Web.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Applies to
GetFromJsonAsync<TValue>(HttpClient, String, JsonTypeInfo<TValue>, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue> (this System.Net.Http.HttpClient client, string? requestUri, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * string * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Value>
<Extension()>
Public Function GetFromJsonAsync(Of TValue) (client As HttpClient, requestUri As String, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional cancellationToken As CancellationToken = Nothing) As Task(Of TValue)
Type Parameters
- TValue
The target type to deserialize to.
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- String
The Uri the request is sent to.
- jsonTypeInfo
- JsonTypeInfo<TValue>
The JsonTypeInfo used to control the deserialization behavior.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Applies to
GetFromJsonAsync<TValue>(HttpClient, Uri, JsonSerializerOptions, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue> (this System.Net.Http.HttpClient client, Uri? requestUri, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * Uri * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Value>
<Extension()>
Public Function GetFromJsonAsync(Of TValue) (client As HttpClient, requestUri As Uri, options As JsonSerializerOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TValue)
Type Parameters
- TValue
The target type to deserialize to.
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- Uri
The Uri the request is sent to.
- options
- JsonSerializerOptions
Options to control the behavior during deserialization. The default options are those specified by Web.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Applies to
GetFromJsonAsync<TValue>(HttpClient, Uri, JsonTypeInfo<TValue>, CancellationToken)
Sends a GET request to the specified Uri and returns the value that results from deserializing the response body as JSON in an asynchronous operation.
public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue> (this System.Net.Http.HttpClient client, Uri? requestUri, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, System.Threading.CancellationToken cancellationToken = default);
static member GetFromJsonAsync : System.Net.Http.HttpClient * Uri * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Value>
<Extension()>
Public Function GetFromJsonAsync(Of TValue) (client As HttpClient, requestUri As Uri, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional cancellationToken As CancellationToken = Nothing) As Task(Of TValue)
Type Parameters
- TValue
The target type to deserialize to.
Parameters
- client
- HttpClient
The client used to send the request.
- requestUri
- Uri
The Uri the request is sent to.
- jsonTypeInfo
- JsonTypeInfo<TValue>
The JsonTypeInfo used to control the deserialization behavior.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
The task object representing the asynchronous operation.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.