JsonSerializer.SerializeToElement Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Överlagringar
| Name | Description |
|---|---|
| SerializeToElement(Object, Type, JsonSerializerContext) |
Konverterar det angivna värdet till en JsonElement. |
| SerializeToElement(Object, Type, JsonSerializerOptions) |
Konverterar det angivna värdet till en JsonElement. |
| SerializeToElement(Object, JsonTypeInfo) |
Konverterar det angivna värdet till en JsonElement. |
| SerializeToElement<TValue>(TValue, JsonSerializerOptions) |
Konverterar det angivna värdet till en JsonElement. |
| SerializeToElement<TValue>(TValue, JsonTypeInfo<TValue>) |
Konverterar det angivna värdet till en JsonElement. |
SerializeToElement(Object, Type, JsonSerializerContext)
Konverterar det angivna värdet till en 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
Parametrar
- value
- Object
Värdet som ska konverteras.
- inputType
- Type
Typ av att value konvertera.
- context
- JsonSerializerContext
En metadataprovider för serialiserbara typer.
Returer
En JsonElement representation av värdet.
Undantag
Det finns inga kompatibla JsonConverter för inputType eller dess serialiserbara medlemmar.
Metoden GetTypeInfo(Type) för de angivna context returnerar null för den typ som ska konverteras.
inputType eller context är null.
Gäller för
SerializeToElement(Object, Type, JsonSerializerOptions)
Konverterar det angivna värdet till en 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
Parametrar
- value
- Object
Värdet som ska konverteras.
- inputType
- Type
Typ av att value konvertera.
- options
- JsonSerializerOptions
Alternativ för att styra konverteringsbeteendet.
Returer
En JsonElement representation av värdet.
- Attribut
Undantag
inputType är inte kompatibelt med value.
inputType är null.
Det finns inga kompatibla JsonConverter för inputType eller dess serialiserbara medlemmar.
Gäller för
SerializeToElement(Object, JsonTypeInfo)
Konverterar det angivna värdet till en 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
Parametrar
- value
- Object
Värdet som ska konverteras.
- jsonTypeInfo
- JsonTypeInfo
Metadata om vilken typ som ska konverteras.
Returer
En JsonElement representation av värdet.
Undantag
jsonTypeInfo är null.
value matchar inte typen av jsonTypeInfo.
Gäller för
SerializeToElement<TValue>(TValue, JsonSerializerOptions)
Konverterar det angivna värdet till en 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
Typparametrar
- TValue
Typ av värde som ska serialiseras.
Parametrar
- value
- TValue
Värdet som ska konverteras.
- options
- JsonSerializerOptions
Alternativ för att styra konverteringsbeteendet.
Returer
En JsonElement representation av JSON-värdet.
- Attribut
Undantag
Det finns inga kompatibla JsonConverter för TValue eller dess serialiserbara medlemmar.
Gäller för
SerializeToElement<TValue>(TValue, JsonTypeInfo<TValue>)
Konverterar det angivna värdet till en 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
Typparametrar
- TValue
Typ av värde som ska serialiseras.
Parametrar
- value
- TValue
Värdet som ska konverteras.
- jsonTypeInfo
- JsonTypeInfo<TValue>
Metadata om vilken typ som ska konverteras.
Returer
En JsonElement representation av värdet.
Undantag
Det finns inga kompatibla JsonConverter för TValue eller dess serialiserbara medlemmar.
jsonTypeInfo är null.