JsonSerializer.SerializeToElement Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Sobrecargas
| Nombre | Description |
|---|---|
| SerializeToElement(Object, Type, JsonSerializerOptions) |
Convierte el valor proporcionado en .JsonElement |
| SerializeToElement(Object, Type, JsonSerializerContext) |
Convierte el valor proporcionado en .JsonElement |
| SerializeToElement(Object, JsonTypeInfo) |
Convierte el valor proporcionado en .JsonElement |
| SerializeToElement<TValue>(TValue, JsonSerializerOptions) |
Convierte el valor proporcionado en .JsonElement |
| SerializeToElement<TValue>(TValue, JsonTypeInfo<TValue>) |
Convierte el valor proporcionado en .JsonElement |
SerializeToElement(Object, Type, JsonSerializerOptions)
Convierte el valor proporcionado 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
Parámetros
- value
- Object
Valor que se va a convertir.
- inputType
- Type
Tipo de que value se va a convertir.
- options
- JsonSerializerOptions
Opciones para controlar el comportamiento de conversión.
Devoluciones
Representación JsonElement del valor.
- Atributos
Excepciones
inputType no es compatible con value.
inputType es null.
No hay compatibilidad JsonConverter para inputType ni para sus miembros serializables.
Se aplica a
SerializeToElement(Object, Type, JsonSerializerContext)
Convierte el valor proporcionado 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
Parámetros
- value
- Object
Valor que se va a convertir.
- inputType
- Type
Tipo de que value se va a convertir.
- context
- JsonSerializerContext
Proveedor de metadatos para tipos serializables.
Devoluciones
Representación JsonElement del valor.
Excepciones
No hay compatibilidad JsonConverter para inputType ni para sus miembros serializables.
El GetTypeInfo(Type) método de las devoluciones proporcionadas contextnull para el tipo que se va a convertir.
inputType o context es null.
Se aplica a
SerializeToElement(Object, JsonTypeInfo)
Convierte el valor proporcionado 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
Parámetros
- value
- Object
Valor que se va a convertir.
- jsonTypeInfo
- JsonTypeInfo
Metadatos sobre el tipo que se va a convertir.
Devoluciones
Representación JsonElement del valor.
Excepciones
jsonTypeInfo es null.
value no coincide con el tipo de jsonTypeInfo.
Se aplica a
SerializeToElement<TValue>(TValue, JsonSerializerOptions)
Convierte el valor proporcionado 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
Parámetros de tipo
- TValue
Tipo del valor que se va a serializar.
Parámetros
- value
- TValue
Valor que se va a convertir.
- options
- JsonSerializerOptions
Opciones para controlar el comportamiento de conversión.
Devoluciones
Representación JsonElement del valor JSON.
- Atributos
Excepciones
No hay compatibilidad JsonConverter para TValue ni para sus miembros serializables.
Se aplica a
SerializeToElement<TValue>(TValue, JsonTypeInfo<TValue>)
Convierte el valor proporcionado 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
Parámetros de tipo
- TValue
Tipo del valor que se va a serializar.
Parámetros
- value
- TValue
Valor que se va a convertir.
- jsonTypeInfo
- JsonTypeInfo<TValue>
Metadatos sobre el tipo que se va a convertir.
Devoluciones
Representación JsonElement del valor.
Excepciones
No hay compatibilidad JsonConverter para TValue ni para sus miembros serializables.
jsonTypeInfo es null.