TypedResults.Json Methode

Definition

Überlädt

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

Erstellt eine JsonHttpResult<TValue> , die das angegebene data Objekt in JSON serialisiert.

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

Erstellt eine JsonHttpResult<TValue> , die das angegebene data Objekt in JSON serialisiert.

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

Erstellt eine JsonHttpResult<TValue> , die das angegebene data Objekt in JSON serialisiert.

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

Erstellt eine JsonHttpResult<TValue> , die das angegebene data Objekt in JSON serialisiert.

public static Microsoft.AspNetCore.Http.HttpResults.JsonHttpResult<TValue> 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.HttpResults.JsonHttpResult<'Value>
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 JsonHttpResult(Of TValue)

Typparameter

TValue

Der Typ des Objekts, das im JSON-Format in den Antworttext serialisiert wird.

Parameter

data
TValue

Das objekt, das als JSON geschrieben werden soll.

options
JsonSerializerOptions

Die Serialisierungsoptionen, die beim Serialisieren des Werts verwendet werden sollen.

contentType
String

Der Inhaltstyp, der für die Antwort festgelegt werden soll.

statusCode
Nullable<Int32>

Der status Code, der für die Antwort festgelegt werden soll.

Gibt zurück

Der erstellte JsonHttpResult<TValue> , der das angegebene data ALS JSON-Format für die Antwort serialisiert.

Hinweise

Aufrufer sollten eine instance der Serialisierungseinstellungen zwischenspeichern, um zu vermeiden, dass zwischengespeicherte Daten bei jedem Aufruf neu erstellen.

Gilt für:

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

Erstellt eine JsonHttpResult<TValue> , die das angegebene data Objekt in JSON serialisiert.

public static Microsoft.AspNetCore.Http.HttpResults.JsonHttpResult<TValue> 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.HttpResults.JsonHttpResult<'Value>
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 JsonHttpResult(Of TValue)

Typparameter

TValue

Der Typ des Objekts, das im JSON-Format in den Antworttext serialisiert wird.

Parameter

data
TValue

Das objekt, das als JSON geschrieben werden soll.

context
JsonSerializerContext

Ein Metadatenanbieter für serialisierbare Typen.

contentType
String

Der Inhaltstyp, der für die Antwort festgelegt werden soll.

statusCode
Nullable<Int32>

Der status Code, der für die Antwort festgelegt werden soll.

Gibt zurück

Der erstellte JsonHttpResult<TValue> , der das angegebene data ALS JSON-Format für die Antwort serialisiert.

Gilt für:

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

Erstellt eine JsonHttpResult<TValue> , die das angegebene data Objekt in JSON serialisiert.

public static Microsoft.AspNetCore.Http.HttpResults.JsonHttpResult<TValue> 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.HttpResults.JsonHttpResult<'Value>
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 JsonHttpResult(Of TValue)

Typparameter

TValue

Der Typ des Objekts, das im JSON-Format in den Antworttext serialisiert wird.

Parameter

data
TValue

Das objekt, das als JSON geschrieben werden soll.

jsonTypeInfo
JsonTypeInfo<TValue>

Metadaten zum zu konvertierenden Typ.

contentType
String

Der Inhaltstyp, der für die Antwort festgelegt werden soll.

statusCode
Nullable<Int32>

Der status Code, der für die Antwort festgelegt werden soll.

Gibt zurück

Der erstellte JsonHttpResult<TValue> , der das angegebene data ALS JSON-Format für die Antwort serialisiert.

Gilt für: