JsonSerializer.Serialize 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 |
|---|---|
| Serialize(Utf8JsonWriter, Object, Type, JsonSerializerContext) |
Escreve um valor JSON (incluindo objetos ou arrays) ao autor fornecido. |
| Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions) |
Escreve a representação JSON do tipo especificado para o autor fornecido. |
| Serialize(Stream, Object, Type, JsonSerializerOptions) |
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo . |
| Serialize(Utf8JsonWriter, Object, JsonTypeInfo) |
Escreve um valor JSON (incluindo objetos ou arrays) ao autor fornecido. |
| Serialize(Stream, Object, Type, JsonSerializerContext) |
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo . |
| Serialize(Object, Type, JsonSerializerOptions) |
Converte o valor de um tipo especificado numa string JSON. |
| Serialize(Stream, Object, JsonTypeInfo) |
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo . |
| Serialize(Object, JsonTypeInfo) |
Converte o valor fornecido num String. |
| Serialize(Object, Type, JsonSerializerContext) |
Converte o valor fornecido num String. |
| Serialize<TValue>(TValue, JsonSerializerOptions) |
Converte o valor de um tipo especificado por um parâmetro genérico de tipo numa cadeia JSON. |
| Serialize<TValue>(TValue, JsonTypeInfo<TValue>) |
Converte o valor fornecido num String. |
| Serialize<TValue>(Stream, TValue, JsonSerializerOptions) |
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo . |
| Serialize<TValue>(Stream, TValue, JsonTypeInfo<TValue>) |
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo . |
| Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions) |
Escreve a representação JSON de um tipo especificado por um parâmetro genérico de tipo ao escritor fornecido. |
| Serialize<TValue>(Utf8JsonWriter, TValue, JsonTypeInfo<TValue>) |
Escreve um valor JSON (incluindo objetos ou arrays) ao autor fornecido. |
Serialize(Utf8JsonWriter, Object, Type, JsonSerializerContext)
Escreve um valor JSON (incluindo objetos ou arrays) ao autor fornecido.
public:
static void Serialize(System::Text::Json::Utf8JsonWriter ^ writer, System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static void Serialize(System.Text.Json.Utf8JsonWriter writer, object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Serialize : System.Text.Json.Utf8JsonWriter * obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> unit
Public Sub Serialize (writer As Utf8JsonWriter, value As Object, inputType As Type, context As JsonSerializerContext)
Parâmetros
- writer
- Utf8JsonWriter
Um escritor JSON para escrever.
- value
- Object
O valor a converter e escrever.
- inputType
- Type
O tipo do value para converter.
- context
- JsonSerializerContext
Um fornecedor de metadados para tipos serializáveis.
Exceções
inputType não é compatível com value.
writer ou 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
Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions)
Escreve a representação JSON do tipo especificado para o autor fornecido.
[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 void Serialize(System.Text.Json.Utf8JsonWriter writer, object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static void Serialize(System.Text.Json.Utf8JsonWriter writer, 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 void Serialize(System.Text.Json.Utf8JsonWriter writer, object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static void Serialize(System.Text.Json.Utf8JsonWriter writer, 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 Serialize : System.Text.Json.Utf8JsonWriter * obj * Type * System.Text.Json.JsonSerializerOptions -> unit
static member Serialize : System.Text.Json.Utf8JsonWriter * obj * Type * System.Text.Json.JsonSerializerOptions -> unit
[<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 Serialize : System.Text.Json.Utf8JsonWriter * obj * Type * System.Text.Json.JsonSerializerOptions -> unit
Public Sub Serialize (writer As Utf8JsonWriter, value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing)
Public Shared Sub Serialize (writer As Utf8JsonWriter, value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing)
Parâmetros
- writer
- Utf8JsonWriter
O escritor JSON a quem escrever.
- value
- Object
O valor a converter e escrever.
- inputType
- Type
O tipo do value para converter.
- options
- JsonSerializerOptions
Opções para controlar o comportamento de serialização.
- Atributos
Exceções
inputType não é compatível com value
writer ou inputType é null.
Não há membros compatíveis JsonConverter para inputType nem serializáveis.
Observações
Eles JsonWriterOptions são usados para criar a instância de que Utf8JsonWriter têm precedência sobre quando JsonSerializerOptions entram em conflito. Assim, JsonWriterOptions.Indented, JsonWriterOptions.SkipValidation, e JsonWriterOptions.Encoder são usados durante a escrita.
Para mais informações, veja Como serializar e desserializar JSON.
Aplica-se a
Serialize(Stream, Object, Type, JsonSerializerOptions)
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo .
[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 void Serialize(System.IO.Stream utf8Json, 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 void Serialize(System.IO.Stream utf8Json, object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static void Serialize(System.IO.Stream utf8Json, 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 Serialize : System.IO.Stream * obj * Type * System.Text.Json.JsonSerializerOptions -> unit
[<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 Serialize : System.IO.Stream * obj * Type * System.Text.Json.JsonSerializerOptions -> unit
static member Serialize : System.IO.Stream * obj * Type * System.Text.Json.JsonSerializerOptions -> unit
Public Sub Serialize (utf8Json As Stream, value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing)
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.
- Atributos
Exceções
inputType não é compatível com value.
utf8Json ou inputType é null.
Não há membros compatíveis JsonConverter para inputType nem serializáveis.
Aplica-se a
Serialize(Utf8JsonWriter, Object, JsonTypeInfo)
Escreve um valor JSON (incluindo objetos ou arrays) ao autor fornecido.
public:
static void Serialize(System::Text::Json::Utf8JsonWriter ^ writer, System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static void Serialize(System.Text.Json.Utf8JsonWriter writer, object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Serialize : System.Text.Json.Utf8JsonWriter * obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> unit
Public Sub Serialize (writer As Utf8JsonWriter, value As Object, jsonTypeInfo As JsonTypeInfo)
Parâmetros
- writer
- Utf8JsonWriter
O escritor para escrever.
- value
- Object
O valor a converter e escrever.
- jsonTypeInfo
- JsonTypeInfo
Metadados sobre o tipo a converter.
Exceções
writer ou jsonTypeInfo é null.
value não corresponde ao tipo de jsonTypeInfo.
Aplica-se a
Serialize(Stream, Object, Type, JsonSerializerContext)
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo .
public:
static void Serialize(System::IO::Stream ^ utf8Json, System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static void Serialize(System.IO.Stream utf8Json, object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Serialize : System.IO.Stream * obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> unit
Public Sub Serialize (utf8Json As Stream, value As Object, inputType As Type, context As JsonSerializerContext)
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.
Exceções
inputType não é compatível com value.
utf8Json, inputType, ou context é null.
Não há membros compatíveis JsonConverter para inputType nem serializáveis.
Aplica-se a
Serialize(Object, Type, JsonSerializerOptions)
Converte o valor de um tipo especificado numa string JSON.
[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 string Serialize(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static string Serialize(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 string Serialize(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static string Serialize(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 Serialize : obj * Type * System.Text.Json.JsonSerializerOptions -> string
static member Serialize : obj * Type * System.Text.Json.JsonSerializerOptions -> string
[<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 Serialize : obj * Type * System.Text.Json.JsonSerializerOptions -> string
Public Function Serialize (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As String
Public Shared Function Serialize (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As String
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
A representação da string JSON do valor.
- 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
Usar a String não é tão eficiente como usar a codificação UTF-8, uma vez que a implementação usa internamente UTF-8. Ver também SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) e SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken).
Para mais informações, veja Como serializar e desserializar JSON.
Aplica-se a
Serialize(Stream, Object, JsonTypeInfo)
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo .
public:
static void Serialize(System::IO::Stream ^ utf8Json, System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static void Serialize(System.IO.Stream utf8Json, object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Serialize : System.IO.Stream * obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> unit
Public Sub Serialize (utf8Json As Stream, value As Object, jsonTypeInfo As JsonTypeInfo)
Parâmetros
- value
- Object
O valor a converter.
- jsonTypeInfo
- JsonTypeInfo
Metadados sobre o tipo a converter.
Exceções
utf8Json é null.
value não corresponde ao tipo de jsonTypeInfo.
Aplica-se a
Serialize(Object, JsonTypeInfo)
Converte o valor fornecido num String.
public:
static System::String ^ Serialize(System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static string Serialize(object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member Serialize : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> string
Public Function Serialize (value As Object, jsonTypeInfo As JsonTypeInfo) As String
Parâmetros
- value
- Object
O valor a converter.
- jsonTypeInfo
- JsonTypeInfo
Metadados sobre o tipo a converter.
Devoluções
Uma String representação do valor.
Exceções
jsonTypeInfo é null.
value não corresponde ao tipo de jsonTypeInfo.
Observações
Usar a String não é tão eficiente como usar a codificação UTF-8, uma vez que a implementação usa internamente UTF-8. Ver também SerializeToUtf8Bytes(Object, JsonTypeInfo) e SerializeAsync(Stream, Object, JsonTypeInfo, CancellationToken).
Aplica-se a
Serialize(Object, Type, JsonSerializerContext)
Converte o valor fornecido num String.
public:
static System::String ^ Serialize(System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static string Serialize(object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member Serialize : obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> string
Public Function Serialize (value As Object, inputType As Type, context As JsonSerializerContext) As String
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 String representação do valor.
Exceções
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.
inputType ou context é null.
Observações
Usar a String não é tão eficiente como usar codificação UTF-8, uma vez que a implementação utiliza internamente UTF-8. Veja SerializeToUtf8Bytes(Object, Type, JsonSerializerContext) também e SerializeAsync(Stream, Object, Type, JsonSerializerContext, CancellationToken).
Aplica-se a
Serialize<TValue>(TValue, JsonSerializerOptions)
Converte o valor de um tipo especificado por um parâmetro genérico de tipo numa cadeia JSON.
[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 string Serialize<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static string Serialize<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 string Serialize<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static string Serialize<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 Serialize : 'Value * System.Text.Json.JsonSerializerOptions -> string
static member Serialize : 'Value * System.Text.Json.JsonSerializerOptions -> string
[<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 Serialize : 'Value * System.Text.Json.JsonSerializerOptions -> string
Public Function Serialize(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As String
Public Shared Function Serialize(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As String
Parâmetros de Tipo Genérico
- TValue
O tipo do valor a serializar.
Parâmetros
- value
- TValue
O valor a converter.
- options
- JsonSerializerOptions
Opções para controlar o comportamento de serialização.
Devoluções
Uma representação JSON string do valor.
- Atributos
Exceções
Não há membros compatíveis JsonConverter para TValue nem serializáveis.
Observações
Usar a String não é tão eficiente como usar a codificação UTF-8, uma vez que a implementação usa internamente UTF-8. Ver também SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) e SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken).
Para mais informações, veja Como serializar e desserializar JSON.
Aplica-se a
Serialize<TValue>(TValue, JsonTypeInfo<TValue>)
Converte o valor fornecido num String.
public:
generic <typename TValue>
static System::String ^ Serialize(TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static string Serialize<TValue>(TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Serialize : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> string
Public Function Serialize(Of TValue) (value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue)) As String
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 String representação do valor.
Exceções
Não há membros compatíveis JsonConverter para TValue nem serializáveis.
jsonTypeInfo é null.
Observações
Usar a String não é tão eficiente como usar a codificação UTF-8, uma vez que a implementação usa internamente UTF-8. Ver também SerializeToUtf8Bytes<TValue>(TValue, JsonTypeInfo<TValue>) e SerializeAsync<TValue>(Stream, TValue, JsonTypeInfo<TValue>, CancellationToken).
Aplica-se a
Serialize<TValue>(Stream, TValue, JsonSerializerOptions)
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo .
[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 void Serialize<TValue>(System.IO.Stream utf8Json, 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 void Serialize<TValue>(System.IO.Stream utf8Json, TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static void Serialize<TValue>(System.IO.Stream utf8Json, 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 Serialize : System.IO.Stream * 'Value * System.Text.Json.JsonSerializerOptions -> unit
[<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 Serialize : System.IO.Stream * 'Value * System.Text.Json.JsonSerializerOptions -> unit
static member Serialize : System.IO.Stream * 'Value * System.Text.Json.JsonSerializerOptions -> unit
Public Sub Serialize(Of TValue) (utf8Json As Stream, value As TValue, Optional options As JsonSerializerOptions = Nothing)
Parâmetros de Tipo Genérico
- TValue
O tipo do valor a serializar.
Parâmetros
- value
- TValue
O valor a converter.
- options
- JsonSerializerOptions
Opções para controlar o comportamento de conversão.
- Atributos
Exceções
utf8Json é null.
Não há membros compatíveis JsonConverter para TValue nem serializáveis.
Aplica-se a
Serialize<TValue>(Stream, TValue, JsonTypeInfo<TValue>)
Converte o valor fornecido para texto JSON codificado em UTF-8 e escreve-o no Streamarquivo .
public:
generic <typename TValue>
static void Serialize(System::IO::Stream ^ utf8Json, TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static void Serialize<TValue>(System.IO.Stream utf8Json, TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Serialize : System.IO.Stream * 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> unit
Public Sub Serialize(Of TValue) (utf8Json As Stream, value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue))
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.
Exceções
utf8Json é null.
Não há membros compatíveis JsonConverter para TValue nem serializáveis.
Aplica-se a
Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions)
Escreve a representação JSON de um tipo especificado por um parâmetro genérico de tipo ao escritor fornecido.
[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 void Serialize<TValue>(System.Text.Json.Utf8JsonWriter writer, TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static void Serialize<TValue>(System.Text.Json.Utf8JsonWriter writer, 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 void Serialize<TValue>(System.Text.Json.Utf8JsonWriter writer, TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static void Serialize<TValue>(System.Text.Json.Utf8JsonWriter writer, 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 Serialize : System.Text.Json.Utf8JsonWriter * 'Value * System.Text.Json.JsonSerializerOptions -> unit
static member Serialize : System.Text.Json.Utf8JsonWriter * 'Value * System.Text.Json.JsonSerializerOptions -> unit
[<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 Serialize : System.Text.Json.Utf8JsonWriter * 'Value * System.Text.Json.JsonSerializerOptions -> unit
Public Sub Serialize(Of TValue) (writer As Utf8JsonWriter, value As TValue, Optional options As JsonSerializerOptions = Nothing)
Public Shared Sub Serialize(Of TValue) (writer As Utf8JsonWriter, value As TValue, Optional options As JsonSerializerOptions = Nothing)
Parâmetros de Tipo Genérico
- TValue
O tipo do valor a serializar.
Parâmetros
- writer
- Utf8JsonWriter
Um escritor JSON para escrever.
- value
- TValue
O valor a converter e escrever.
- options
- JsonSerializerOptions
Opções para controlar o comportamento de serialização.
- Atributos
Exceções
writer é null.
Não há membros compatíveis JsonConverter para TValue nem serializáveis.
Observações
Eles JsonWriterOptions são usados para criar a instância de que Utf8JsonWriter têm precedência sobre quando JsonSerializerOptions entram em conflito. Assim, JsonWriterOptions.Indented, JsonWriterOptions.SkipValidation, e JsonWriterOptions.Encoder são usados durante a escrita.
Para mais informações, veja Como serializar e desserializar JSON.
Aplica-se a
Serialize<TValue>(Utf8JsonWriter, TValue, JsonTypeInfo<TValue>)
Escreve um valor JSON (incluindo objetos ou arrays) ao autor fornecido.
public:
generic <typename TValue>
static void Serialize(System::Text::Json::Utf8JsonWriter ^ writer, TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static void Serialize<TValue>(System.Text.Json.Utf8JsonWriter writer, TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member Serialize : System.Text.Json.Utf8JsonWriter * 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> unit
Public Sub Serialize(Of TValue) (writer As Utf8JsonWriter, value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue))
Parâmetros de Tipo Genérico
- TValue
O tipo do valor a serializar.
Parâmetros
- writer
- Utf8JsonWriter
O escritor para escrever.
- value
- TValue
O valor a converter e escrever.
- jsonTypeInfo
- JsonTypeInfo<TValue>
Metadados sobre o tipo a converter.
Exceções
writer ou jsonTypeInfo é null.
Não há membros compatíveis JsonConverter para TValue nem serializáveis.