HttpClientJsonExtensions.GetFromJsonAsync 方法

定義

多載

GetFromJsonAsync(HttpClient, String, Type, CancellationToken)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
String

傳送要求的目標 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.

傳回

Task<Object>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

備註

這個方法會使用還原序列化的 JsonSerializerDefaults.Web 選項,而還原序列化 JsonSerializer 方法預設不會。This method uses JsonSerializerDefaults.Web options for deserialization, whereas JsonSerializer deserialization methods do not, by default.

適用於

GetFromJsonAsync(HttpClient, Uri, Type, CancellationToken)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
Uri

傳送要求的目標 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.

傳回

Task<Object>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

備註

這個方法會使用還原序列化的 JsonSerializerDefaults.Web 選項,而還原序列化 JsonSerializer 方法預設不會。This method uses JsonSerializerDefaults.Web options for deserialization, whereas JsonSerializer deserialization methods do not, by default.

適用於

GetFromJsonAsync(HttpClient, String, Type, JsonSerializerOptions, CancellationToken)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
String

傳送要求的目標 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. 預設選項是 Web 所指定的選項。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.

傳回

Task<Object>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

適用於

GetFromJsonAsync(HttpClient, Uri, Type, JsonSerializerOptions, CancellationToken)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
Uri

傳送要求的目標 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. 預設選項是 Web 所指定的選項。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.

傳回

Task<Object>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

適用於

GetFromJsonAsync<TValue>(HttpClient, String, CancellationToken)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

類型參數

TValue

要還原序列化的目標型別。The target type to deserialize to.

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
String

傳送要求的目標 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.

傳回

Task<TValue>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

備註

這個方法會使用還原序列化的 JsonSerializerDefaults.Web 選項,而還原序列化 JsonSerializer 方法預設不會。This method uses JsonSerializerDefaults.Web options for deserialization, whereas JsonSerializer deserialization methods do not, by default.

適用於

GetFromJsonAsync<TValue>(HttpClient, Uri, CancellationToken)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

類型參數

TValue

要還原序列化的目標型別。The target type to deserialize to.

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
Uri

傳送要求的目標 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.

傳回

Task<TValue>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

備註

這個方法會使用還原序列化的 JsonSerializerDefaults.Web 選項,而還原序列化 JsonSerializer 方法預設不會。This method uses JsonSerializerDefaults.Web options for deserialization, whereas JsonSerializer deserialization methods do not, by default.

適用於

GetFromJsonAsync<TValue>(HttpClient, String, JsonSerializerOptions, CancellationToken)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

類型參數

TValue

要還原序列化的目標型別。The target type to deserialize to.

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
String

傳送要求的目標 URI。The Uri the request is sent to.

options
JsonSerializerOptions

在還原序列化期間控制行為的選項。Options to control the behavior during deserialization. 預設選項是 Web 所指定的選項。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.

傳回

Task<TValue>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

適用於

GetFromJsonAsync<TValue>(HttpClient, Uri, JsonSerializerOptions, CancellationToken)

將 GET 要求傳送至指定的 URI,並傳回在非同步作業中,將回應主體作為 JSON 還原序列化後所產生的值。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)

類型參數

TValue

要還原序列化的目標型別。The target type to deserialize to.

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
Uri

傳送要求的目標 URI。The Uri the request is sent to.

options
JsonSerializerOptions

在還原序列化期間控制行為的選項。Options to control the behavior during deserialization. 預設選項是 Web 所指定的選項。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.

傳回

Task<TValue>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

適用於