JsonSerializer.SerializeToElement Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Surcharges
| Nom | Description |
|---|---|
| SerializeToElement(Object, Type, JsonSerializerContext) |
Convertit la valeur fournie en un JsonElement. |
| SerializeToElement(Object, Type, JsonSerializerOptions) |
Convertit la valeur fournie en un JsonElement. |
| SerializeToElement(Object, JsonTypeInfo) |
Convertit la valeur fournie en un JsonElement. |
| SerializeToElement<TValue>(TValue, JsonSerializerOptions) |
Convertit la valeur fournie en un JsonElement. |
| SerializeToElement<TValue>(TValue, JsonTypeInfo<TValue>) |
Convertit la valeur fournie en un JsonElement. |
SerializeToElement(Object, Type, JsonSerializerContext)
Convertit la valeur fournie en un JsonElement.
public:
static System::Text::Json::JsonElement SerializeToElement(System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static System.Text.Json.JsonElement SerializeToElement(object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member SerializeToElement : obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> System.Text.Json.JsonElement
Public Function SerializeToElement (value As Object, inputType As Type, context As JsonSerializerContext) As JsonElement
Paramètres
- value
- Object
Valeur à convertir.
- inputType
- Type
Type de la value conversion.
- context
- JsonSerializerContext
Fournisseur de métadonnées pour les types sérialisables.
Retours
Représentation JsonElement de la valeur.
Exceptions
Il n’existe aucune compatibilité JsonConverter pour inputType ses membres sérialisables.
Méthode GetTypeInfo(Type) des retours null fournis context pour le type à convertir.
inputType ou context est null.
S’applique à
SerializeToElement(Object, Type, JsonSerializerOptions)
Convertit la valeur fournie en un JsonElement.
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Text.Json.JsonElement SerializeToElement(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Text.Json.JsonElement SerializeToElement(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static System.Text.Json.JsonElement SerializeToElement(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member SerializeToElement : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonElement
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member SerializeToElement : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonElement
static member SerializeToElement : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonElement
Public Function SerializeToElement (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As JsonElement
Paramètres
- value
- Object
Valeur à convertir.
- inputType
- Type
Type de la value conversion.
- options
- JsonSerializerOptions
Options permettant de contrôler le comportement de conversion.
Retours
Représentation JsonElement de la valeur.
- Attributs
Exceptions
inputType n’est pas compatible avec value.
inputType a la valeur null.
Il n’existe aucune compatibilité JsonConverter pour inputType ses membres sérialisables.
S’applique à
SerializeToElement(Object, JsonTypeInfo)
Convertit la valeur fournie en un JsonElement.
public:
static System::Text::Json::JsonElement SerializeToElement(System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static System.Text.Json.JsonElement SerializeToElement(object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member SerializeToElement : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> System.Text.Json.JsonElement
Public Function SerializeToElement (value As Object, jsonTypeInfo As JsonTypeInfo) As JsonElement
Paramètres
- value
- Object
Valeur à convertir.
- jsonTypeInfo
- JsonTypeInfo
Métadonnées sur le type à convertir.
Retours
Représentation JsonElement de la valeur.
Exceptions
jsonTypeInfo a la valeur null.
value ne correspond pas au type de jsonTypeInfo.
S’applique à
SerializeToElement<TValue>(TValue, JsonSerializerOptions)
Convertit la valeur fournie en un JsonElement.
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Text.Json.JsonElement SerializeToElement<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
public static System.Text.Json.JsonElement SerializeToElement<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static System.Text.Json.JsonElement SerializeToElement<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member SerializeToElement : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonElement
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member SerializeToElement : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonElement
static member SerializeToElement : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonElement
Public Function SerializeToElement(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As JsonElement
Paramètres de type
- TValue
Type de la valeur à sérialiser.
Paramètres
- value
- TValue
Valeur à convertir.
- options
- JsonSerializerOptions
Options permettant de contrôler le comportement de conversion.
Retours
Représentation JsonElement de la valeur JSON.
- Attributs
Exceptions
Il n’existe aucune compatibilité JsonConverter pour TValue ses membres sérialisables.
S’applique à
SerializeToElement<TValue>(TValue, JsonTypeInfo<TValue>)
Convertit la valeur fournie en un JsonElement.
public:
generic <typename TValue>
static System::Text::Json::JsonElement SerializeToElement(TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static System.Text.Json.JsonElement SerializeToElement<TValue>(TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member SerializeToElement : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> System.Text.Json.JsonElement
Public Function SerializeToElement(Of TValue) (value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue)) As JsonElement
Paramètres de type
- TValue
Type de la valeur à sérialiser.
Paramètres
- value
- TValue
Valeur à convertir.
- jsonTypeInfo
- JsonTypeInfo<TValue>
Métadonnées sur le type à convertir.
Retours
Représentation JsonElement de la valeur.
Exceptions
Il n’existe aucune compatibilité JsonConverter pour TValue ses membres sérialisables.
jsonTypeInfo a la valeur null.