Results.Json 方法

定義

多載

Json(Object, JsonSerializerOptions, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

Json(Object, JsonTypeInfo, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

Json(Object, Type, JsonSerializerContext, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

Json<TValue>(TValue, JsonSerializerOptions, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

Json<TValue>(TValue, JsonSerializerContext, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

Json<TValue>(TValue, JsonTypeInfo<TValue>, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

Json(Object, JsonSerializerOptions, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

public static Microsoft.AspNetCore.Http.IResult Json (object? data, System.Text.Json.JsonSerializerOptions? options = default, string? contentType = default, int? statusCode = default);
static member Json : obj * System.Text.Json.JsonSerializerOptions * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json (data As Object, Optional options As JsonSerializerOptions = Nothing, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult

參數

data
Object

要寫入為 JSON 的物件。

options
JsonSerializerOptions

序列化值時要使用的序列化程式選項。

contentType
String

回應上要設定的內容類型。

statusCode
Nullable<Int32>

回應上要設定的狀態碼。

傳回

建立 JsonHttpResult<TValue> 的 ,會將指定的 data 序列化為回應的 JSON 格式。

備註

呼叫端應該快取序列化程式設定的實例,以避免每次呼叫重新建立快取的資料。

適用於

Json(Object, JsonTypeInfo, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

public static Microsoft.AspNetCore.Http.IResult Json (object? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo, string? contentType = default, int? statusCode = default);
static member Json : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json (data As Object, jsonTypeInfo As JsonTypeInfo, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult

參數

data
Object

要寫入為 JSON 的物件。

jsonTypeInfo
JsonTypeInfo

要轉換之型別的相關中繼資料。

contentType
String

回應上要設定的內容類型。

statusCode
Nullable<Int32>

回應上要設定的狀態碼。

傳回

建立 JsonHttpResult<TValue> 的 ,會將指定的 data 序列化為回應的 JSON 格式。

備註

呼叫端應該快取序列化程式設定的實例,以避免每次呼叫重新建立快取的資料。

適用於

Json(Object, Type, JsonSerializerContext, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

public static Microsoft.AspNetCore.Http.IResult Json (object? data, Type type, System.Text.Json.Serialization.JsonSerializerContext context, string? contentType = default, int? statusCode = default);
static member Json : obj * Type * System.Text.Json.Serialization.JsonSerializerContext * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json (data As Object, type As Type, context As JsonSerializerContext, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult

參數

data
Object

要寫入為 JSON 的物件。

type
Type

要寫入之物件的類型。

context
JsonSerializerContext

可序列化類型的中繼資料提供者。

contentType
String

回應上要設定的內容類型。

statusCode
Nullable<Int32>

回應上要設定的狀態碼。

傳回

建立 JsonHttpResult<TValue> 的 ,會將指定的 data 序列化為回應的 JSON 格式。

備註

呼叫端應該快取序列化程式設定的實例,以避免每次呼叫重新建立快取的資料。

適用於

Json<TValue>(TValue, JsonSerializerOptions, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

public static Microsoft.AspNetCore.Http.IResult Json<TValue> (TValue? data, System.Text.Json.JsonSerializerOptions? options = default, string? contentType = default, int? statusCode = default);
static member Json : 'Value * System.Text.Json.JsonSerializerOptions * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json(Of TValue) (data As TValue, Optional options As JsonSerializerOptions = Nothing, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult

類型參數

TValue

參數

data
TValue

要寫入為 JSON 的物件。

options
JsonSerializerOptions

序列化值時要使用的序列化程式選項。

contentType
String

回應上要設定的內容類型。

statusCode
Nullable<Int32>

回應上要設定的狀態碼。

傳回

建立 JsonHttpResult<TValue> 的 ,會將指定的 data 序列化為回應的 JSON 格式。

備註

呼叫端應該快取序列化程式設定的實例,以避免每次呼叫重新建立快取的資料。

適用於

Json<TValue>(TValue, JsonSerializerContext, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

public static Microsoft.AspNetCore.Http.IResult Json<TValue> (TValue? data, System.Text.Json.Serialization.JsonSerializerContext context, string? contentType = default, int? statusCode = default);
static member Json : 'Value * System.Text.Json.Serialization.JsonSerializerContext * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json(Of TValue) (data As TValue, context As JsonSerializerContext, Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult

類型參數

TValue

參數

data
TValue

要寫入為 JSON 的物件。

context
JsonSerializerContext

可序列化類型的中繼資料提供者。

contentType
String

回應上要設定的內容類型。

statusCode
Nullable<Int32>

回應上要設定的狀態碼。

傳回

建立 JsonHttpResult<TValue> 的 ,會將指定的 data 序列化為回應的 JSON 格式。

備註

呼叫端應該快取序列化程式設定的實例,以避免每次呼叫重新建立快取的資料。

適用於

Json<TValue>(TValue, JsonTypeInfo<TValue>, String, Nullable<Int32>)

建立 , IResult 將指定的 data 物件序列化為 JSON。

public static Microsoft.AspNetCore.Http.IResult Json<TValue> (TValue? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, string? contentType = default, int? statusCode = default);
static member Json : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * string * Nullable<int> -> Microsoft.AspNetCore.Http.IResult
Public Shared Function Json(Of TValue) (data As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional contentType As String = Nothing, Optional statusCode As Nullable(Of Integer) = Nothing) As IResult

類型參數

TValue

參數

data
TValue

要寫入為 JSON 的物件。

jsonTypeInfo
JsonTypeInfo<TValue>

要轉換之型別的相關中繼資料。

contentType
String

回應上要設定的內容類型。

statusCode
Nullable<Int32>

回應上要設定的狀態碼。

傳回

建立 JsonHttpResult<TValue> 的 ,會將指定的 data 序列化為回應的 JSON 格式。

備註

呼叫端應該快取序列化程式設定的實例,以避免每次呼叫重新建立快取的資料。

適用於