JsonSerializer.SerializeToUtf8Bytes Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Sobrecargas
| Name | Description |
|---|---|
| SerializeToUtf8Bytes(Object, JsonTypeInfo) |
Converte o valor fornecido num Byte array. |
| SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) |
Converte um valor do tipo especificado numa string JSON, codificada como bytes UTF-8. |
| SerializeToUtf8Bytes(Object, Type, JsonSerializerContext) |
Converte o valor fornecido num Byte array. |
| SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions) |
Converte o valor de um tipo especificado por um parâmetro genérico de tipo numa cadeia JSON, codificada como bytes UTF-8. |
| SerializeToUtf8Bytes<TValue>(TValue, JsonTypeInfo<TValue>) |
Converte o valor fornecido num Byte array. |
SerializeToUtf8Bytes(Object, JsonTypeInfo)
Converte o valor fornecido num Byte array.
public:
static cli::array <System::Byte> ^ SerializeToUtf8Bytes(System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static byte[] SerializeToUtf8Bytes(object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member SerializeToUtf8Bytes : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> byte[]
Public Function SerializeToUtf8Bytes (value As Object, jsonTypeInfo As JsonTypeInfo) As Byte()
Parâmetros
- value
- Object
O valor a converter.
- jsonTypeInfo
- JsonTypeInfo
Metadados sobre o tipo a converter.
Devoluções
Uma representação UTF-8 do valor.
Exceções
jsonTypeInfo é null.
value não corresponde ao tipo de jsonTypeInfo.
Aplica-se a
SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions)
Converte um valor do tipo especificado numa string JSON, codificada como bytes UTF-8.
[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 byte[] SerializeToUtf8Bytes(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static byte[] SerializeToUtf8Bytes(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 byte[] SerializeToUtf8Bytes(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static byte[] SerializeToUtf8Bytes(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 SerializeToUtf8Bytes : obj * Type * System.Text.Json.JsonSerializerOptions -> byte[]
static member SerializeToUtf8Bytes : obj * Type * System.Text.Json.JsonSerializerOptions -> byte[]
[<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 SerializeToUtf8Bytes : obj * Type * System.Text.Json.JsonSerializerOptions -> byte[]
Public Function SerializeToUtf8Bytes (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As Byte()
Public Shared Function SerializeToUtf8Bytes (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As Byte()
Parâmetros
- value
- Object
O valor a converter.
- inputType
- Type
O tipo do value para converter.
- options
- JsonSerializerOptions
Opções para controlar o comportamento de conversão.
Devoluções
Uma representação em cadeia JSON do valor, codificada como bytes UTF-8.
- Atributos
Exceções
inputType não é compatível com value.
inputType é null.
Não há membros compatíveis JsonConverter para inputType nem serializáveis.
Observações
Para mais informações, veja Como serializar e desserializar JSON.
Aplica-se a
SerializeToUtf8Bytes(Object, Type, JsonSerializerContext)
Converte o valor fornecido num Byte array.
public:
static cli::array <System::Byte> ^ SerializeToUtf8Bytes(System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static byte[] SerializeToUtf8Bytes(object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member SerializeToUtf8Bytes : obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> byte[]
Public Function SerializeToUtf8Bytes (value As Object, inputType As Type, context As JsonSerializerContext) As Byte()
Parâmetros
- value
- Object
O valor a converter.
- inputType
- Type
O tipo do value para converter.
- context
- JsonSerializerContext
Um fornecedor de metadados para tipos serializáveis.
Devoluções
Uma representação UTF-8 do valor.
Exceções
inputType não é compatível com value.
inputType é null.
Não há membros compatíveis JsonConverter para inputType nem serializáveis.
O GetTypeInfo(Type) método fornecido context retorna null para o tipo a converter.
Aplica-se a
SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)
Converte o valor de um tipo especificado por um parâmetro genérico de tipo numa cadeia JSON, codificada como bytes UTF-8.
[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 byte[] SerializeToUtf8Bytes<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static byte[] SerializeToUtf8Bytes<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 byte[] SerializeToUtf8Bytes<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static byte[] SerializeToUtf8Bytes<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 SerializeToUtf8Bytes : 'Value * System.Text.Json.JsonSerializerOptions -> byte[]
static member SerializeToUtf8Bytes : 'Value * System.Text.Json.JsonSerializerOptions -> byte[]
[<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 SerializeToUtf8Bytes : 'Value * System.Text.Json.JsonSerializerOptions -> byte[]
Public Function SerializeToUtf8Bytes(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As Byte()
Public Shared Function SerializeToUtf8Bytes(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As Byte()
Parâmetros de Tipo Genérico
- TValue
O tipo do valor.
Parâmetros
- value
- TValue
O valor a converter.
- options
- JsonSerializerOptions
Opções para controlar o comportamento de conversão.
Devoluções
Uma representação em cadeia JSON do valor, codificada como bytes UTF-8.
- Atributos
Exceções
Não há membros compatíveis JsonConverter para TValue nem serializáveis.
Observações
Para mais informações, veja Como serializar e desserializar JSON.
Aplica-se a
SerializeToUtf8Bytes<TValue>(TValue, JsonTypeInfo<TValue>)
Converte o valor fornecido num Byte array.
public:
generic <typename TValue>
static cli::array <System::Byte> ^ SerializeToUtf8Bytes(TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static byte[] SerializeToUtf8Bytes<TValue>(TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member SerializeToUtf8Bytes : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> byte[]
Public Function SerializeToUtf8Bytes(Of TValue) (value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue)) As Byte()
Parâmetros de Tipo Genérico
- TValue
O tipo do valor a serializar.
Parâmetros
- value
- TValue
O valor a converter.
- jsonTypeInfo
- JsonTypeInfo<TValue>
Metadados sobre o tipo a converter.
Devoluções
Uma representação UTF-8 do valor.
Exceções
Não há membros compatíveis JsonConverter para TValue nem serializáveis.
jsonTypeInfo é null.