JsonSerializer.Serialize Méthode

Définition

Surcharges

Nom Description
Serialize(Object, JsonTypeInfo)

Convertit la valeur fournie en un String.

Serialize(Stream, Object, JsonTypeInfo)

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

Serialize(Object, Type, JsonSerializerOptions)

Convertit la valeur d’un type spécifié en chaîne JSON.

Serialize(Object, Type, JsonSerializerContext)

Convertit la valeur fournie en un String.

Serialize(Utf8JsonWriter, Object, JsonTypeInfo)

Écrit une valeur JSON (y compris des objets ou des tableaux) dans l’enregistreur fourni.

Serialize(Stream, Object, Type, JsonSerializerOptions)

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

Serialize(Stream, Object, Type, JsonSerializerContext)

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions)

Écrit la représentation JSON du type spécifié dans l’enregistreur fourni.

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerContext)

Écrit une valeur JSON (y compris des objets ou des tableaux) dans l’enregistreur fourni.

Serialize<TValue>(Utf8JsonWriter, TValue, JsonTypeInfo<TValue>)

Écrit une valeur JSON (y compris des objets ou des tableaux) dans l’enregistreur fourni.

Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions)

Écrit la représentation JSON d’un type spécifié par un paramètre de type générique dans l’enregistreur fourni.

Serialize<TValue>(Stream, TValue, JsonTypeInfo<TValue>)

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

Serialize<TValue>(TValue, JsonSerializerOptions)

Convertit la valeur d’un type spécifié par un paramètre de type générique en chaîne JSON.

Serialize<TValue>(TValue, JsonTypeInfo<TValue>)

Convertit la valeur fournie en un String.

Serialize<TValue>(Stream, TValue, JsonSerializerOptions)

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

Serialize(Object, JsonTypeInfo)

Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs

Convertit la valeur fournie en un 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

Paramètres

value
Object

Valeur à convertir.

jsonTypeInfo
JsonTypeInfo

Métadonnées sur le type à convertir.

Retours

Représentation String de la valeur.

Exceptions

jsonTypeInfo a la valeur null.

value ne correspond pas au type de jsonTypeInfo.

Remarques

L’utilisation d’un String encodage UTF-8 n’est pas aussi efficace que l’utilisation de l’encodage UTF-8, car l’implémentation utilise en interne UTF-8. Voir aussi SerializeToUtf8Bytes(Object, JsonTypeInfo) et SerializeAsync(Stream, Object, JsonTypeInfo, CancellationToken).

S’applique à

Serialize(Stream, Object, JsonTypeInfo)

Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

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)

Paramètres

utf8Json
Stream

UTF-8 Stream à écrire.

value
Object

Valeur à convertir.

jsonTypeInfo
JsonTypeInfo

Métadonnées sur le type à convertir.

Exceptions

utf8Json a la valeur null.

value ne correspond pas au type de jsonTypeInfo.

S’applique à

Serialize(Object, Type, JsonSerializerOptions)

Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs

Convertit la valeur d’un type spécifié en chaîne 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

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 sous forme de chaîne JSON 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.

Remarques

L’utilisation d’un String encodage UTF-8 n’est pas aussi efficace que l’utilisation de l’encodage UTF-8, car l’implémentation utilise en interne UTF-8. Voir aussi SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) et SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken).

Pour plus d’informations, consultez Comment sérialiser et désérialiser JSON.

S’applique à

Serialize(Object, Type, JsonSerializerContext)

Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs

Convertit la valeur fournie en un 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

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 String de la valeur.

Exceptions

Il n’existe aucune compatibilité JsonConverter pour inputType ses membres sérialisables.

Méthode GetTypeInfo(Type) des retours context fournis null pour le type à convertir.

inputType ou context est null.

Remarques

L’utilisation d’un String encodage UTF-8 n’est pas aussi efficace que l’encodage UTF-8, car l’implémentation utilise en interne UTF-8. SerializeToUtf8Bytes(Object, Type, JsonSerializerContext) Voir aussi et SerializeAsync(Stream, Object, Type, JsonSerializerContext, CancellationToken).

S’applique à

Serialize(Utf8JsonWriter, Object, JsonTypeInfo)

Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs

Écrit une valeur JSON (y compris des objets ou des tableaux) dans l’enregistreur fourni.

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)

Paramètres

writer
Utf8JsonWriter

Enregistreur à écrire.

value
Object

Valeur à convertir et à écrire.

jsonTypeInfo
JsonTypeInfo

Métadonnées sur le type à convertir.

Exceptions

writer ou jsonTypeInfo est null.

value ne correspond pas au type de jsonTypeInfo.

S’applique à

Serialize(Stream, Object, Type, JsonSerializerOptions)

Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

[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)

Paramètres

utf8Json
Stream

UTF-8 Stream à écrire.

value
Object

Valeur à convertir.

inputType
Type

Type de la value conversion.

options
JsonSerializerOptions

Options permettant de contrôler le comportement de conversion.

Attributs

Exceptions

inputType n’est pas compatible avec value.

utf8Json ou inputType est null.

Il n’existe aucune compatibilité JsonConverter pour inputType ses membres sérialisables.

S’applique à

Serialize(Stream, Object, Type, JsonSerializerContext)

Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

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)

Paramètres

utf8Json
Stream

UTF-8 Stream à écrire.

value
Object

Valeur à convertir.

inputType
Type

Type de la value conversion.

context
JsonSerializerContext

Fournisseur de métadonnées pour les types sérialisables.

Exceptions

inputType n’est pas compatible avec value.

utf8Json, inputTypeou context est null.

Il n’existe aucune compatibilité JsonConverter pour inputType ses membres sérialisables.

S’applique à

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions)

Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs

Écrit la représentation JSON du type spécifié dans l’enregistreur fourni.

[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)

Paramètres

writer
Utf8JsonWriter

Enregistreur JSON dans lequel écrire.

value
Object

Valeur à convertir et à écrire.

inputType
Type

Type de la value conversion.

options
JsonSerializerOptions

Options pour contrôler le comportement de sérialisation.

Attributs

Exceptions

inputType n’est pas compatible avec value

writer ou inputType est null.

Il n’existe aucune compatibilité JsonConverter pour inputType ses membres sérialisables.

Remarques

Utilisé JsonWriterOptions pour créer l’instance de l’instance Utf8JsonWriter prioritaire sur le JsonSerializerOptions moment où ils sont en conflit. Par conséquent, JsonWriterOptions.Indented, JsonWriterOptions.SkipValidationet JsonWriterOptions.Encoder sont utilisés lors de l’écriture.

Pour plus d’informations, consultez Comment sérialiser et désérialiser JSON.

S’applique à

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerContext)

Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs

Écrit une valeur JSON (y compris des objets ou des tableaux) dans l’enregistreur fourni.

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)

Paramètres

writer
Utf8JsonWriter

Enregistreur JSON dans lequel écrire.

value
Object

Valeur à convertir et à écrire.

inputType
Type

Type de la value conversion.

context
JsonSerializerContext

Fournisseur de métadonnées pour les types sérialisables.

Exceptions

inputType n’est pas compatible avec value.

writer ou inputType est null.

Il n’existe aucune compatibilité JsonConverter pour inputType ses membres sérialisables.

Méthode GetTypeInfo(Type) des retours context fournis null pour le type à convertir.

S’applique à

Serialize<TValue>(Utf8JsonWriter, TValue, JsonTypeInfo<TValue>)

Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs

Écrit une valeur JSON (y compris des objets ou des tableaux) dans l’enregistreur fourni.

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))

Paramètres de type

TValue

Type de la valeur à sérialiser.

Paramètres

writer
Utf8JsonWriter

Enregistreur à écrire.

value
TValue

Valeur à convertir et à écrire.

jsonTypeInfo
JsonTypeInfo<TValue>

Métadonnées sur le type à convertir.

Exceptions

writer ou jsonTypeInfo est null.

Il n’existe aucune compatibilité JsonConverter pour TValue ses membres sérialisables.

S’applique à

Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions)

Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs
Source:
JsonSerializer.Write.Utf8JsonWriter.cs

Écrit la représentation JSON d’un type spécifié par un paramètre de type générique dans l’enregistreur fourni.

[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)

Paramètres de type

TValue

Type de la valeur à sérialiser.

Paramètres

writer
Utf8JsonWriter

Enregistreur JSON dans lequel écrire.

value
TValue

Valeur à convertir et à écrire.

options
JsonSerializerOptions

Options pour contrôler le comportement de sérialisation.

Attributs

Exceptions

writer a la valeur null.

Il n’existe aucune compatibilité JsonConverter pour TValue ses membres sérialisables.

Remarques

Utilisé JsonWriterOptions pour créer l’instance de l’instance Utf8JsonWriter prioritaire sur le JsonSerializerOptions moment où ils sont en conflit. Par conséquent, JsonWriterOptions.Indented, JsonWriterOptions.SkipValidationet JsonWriterOptions.Encoder sont utilisés lors de l’écriture.

Pour plus d’informations, consultez Comment sérialiser et désérialiser JSON.

S’applique à

Serialize<TValue>(Stream, TValue, JsonTypeInfo<TValue>)

Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

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))

Paramètres de type

TValue

Type de la valeur à sérialiser.

Paramètres

utf8Json
Stream

UTF-8 Stream à écrire.

value
TValue

Valeur à convertir.

jsonTypeInfo
JsonTypeInfo<TValue>

Métadonnées sur le type à convertir.

Exceptions

utf8Json a la valeur null.

Il n’existe aucune compatibilité JsonConverter pour TValue ses membres sérialisables.

S’applique à

Serialize<TValue>(TValue, JsonSerializerOptions)

Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs

Convertit la valeur d’un type spécifié par un paramètre de type générique en chaîne 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

Paramètres de type

TValue

Type de la valeur à sérialiser.

Paramètres

value
TValue

Valeur à convertir.

options
JsonSerializerOptions

Options pour contrôler le comportement de sérialisation.

Retours

Représentation sous forme de chaîne JSON de la valeur.

Attributs

Exceptions

Il n’existe aucune compatibilité JsonConverter pour TValue ses membres sérialisables.

Remarques

L’utilisation d’un String encodage UTF-8 n’est pas aussi efficace que l’utilisation de l’encodage UTF-8, car l’implémentation utilise en interne UTF-8. Voir aussi SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) et SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken).

Pour plus d’informations, consultez Comment sérialiser et désérialiser JSON.

S’applique à

Serialize<TValue>(TValue, JsonTypeInfo<TValue>)

Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs
Source:
JsonSerializer.Write.String.cs

Convertit la valeur fournie en un 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

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 String de la valeur.

Exceptions

Il n’existe aucune compatibilité JsonConverter pour TValue ses membres sérialisables.

jsonTypeInfo a la valeur null.

Remarques

L’utilisation d’un String encodage UTF-8 n’est pas aussi efficace que l’utilisation de l’encodage UTF-8, car l’implémentation utilise en interne UTF-8. Voir aussi SerializeToUtf8Bytes<TValue>(TValue, JsonTypeInfo<TValue>) et SerializeAsync<TValue>(Stream, TValue, JsonTypeInfo<TValue>, CancellationToken).

S’applique à

Serialize<TValue>(Stream, TValue, JsonSerializerOptions)

Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs
Source:
JsonSerializer.Write.Stream.cs

Convertit la valeur fournie en texte JSON encodé en UTF-8 et l’écrit dans le Streamfichier .

[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)

Paramètres de type

TValue

Type de la valeur à sérialiser.

Paramètres

utf8Json
Stream

UTF-8 Stream à écrire.

value
TValue

Valeur à convertir.

options
JsonSerializerOptions

Options permettant de contrôler le comportement de conversion.

Attributs

Exceptions

utf8Json a la valeur null.

Il n’existe aucune compatibilité JsonConverter pour TValue ses membres sérialisables.

S’applique à