JsonSerializer.Serialize Methode

Definitie

Overloads

Name Description
Serialize(Object, JsonTypeInfo)

Converteert de opgegeven waarde naar een String.

Serialize(Stream, Object, JsonTypeInfo)

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

Serialize(Object, Type, JsonSerializerOptions)

Converteert de waarde van een opgegeven type naar een JSON-tekenreeks.

Serialize(Object, Type, JsonSerializerContext)

Converteert de opgegeven waarde naar een String.

Serialize(Utf8JsonWriter, Object, JsonTypeInfo)

Hiermee schrijft u één JSON-waarde (inclusief objecten of matrices) naar de opgegeven schrijver.

Serialize(Stream, Object, Type, JsonSerializerOptions)

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

Serialize(Stream, Object, Type, JsonSerializerContext)

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions)

Hiermee schrijft u de JSON-weergave van het opgegeven type naar de opgegeven schrijver.

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerContext)

Hiermee schrijft u één JSON-waarde (inclusief objecten of matrices) naar de opgegeven schrijver.

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

Hiermee schrijft u één JSON-waarde (inclusief objecten of matrices) naar de opgegeven schrijver.

Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions)

Hiermee schrijft u de JSON-weergave van een type dat is opgegeven door een algemene typeparameter naar de opgegeven schrijver.

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

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

Serialize<TValue>(TValue, JsonSerializerOptions)

Converteert de waarde van een type dat is opgegeven door een algemene typeparameter naar een JSON-tekenreeks.

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

Converteert de opgegeven waarde naar een String.

Serialize<TValue>(Stream, TValue, JsonSerializerOptions)

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

Serialize(Object, JsonTypeInfo)

Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs

Converteert de opgegeven waarde naar een 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

Parameters

value
Object

De waarde die moet worden geconverteerd.

jsonTypeInfo
JsonTypeInfo

Metagegevens over het type dat moet worden geconverteerd.

Retouren

Een String weergave van de waarde.

Uitzonderingen

jsonTypeInfo is null.

value komt niet overeen met het type jsonTypeInfo.

Opmerkingen

Het gebruik van een String is niet zo efficiënt als het gebruik van UTF-8-codering, omdat de implementatie intern gebruikmaakt van UTF-8. Zie ook SerializeToUtf8Bytes(Object, JsonTypeInfo) en SerializeAsync(Stream, Object, JsonTypeInfo, CancellationToken).

Van toepassing op

Serialize(Stream, Object, JsonTypeInfo)

Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

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)

Parameters

utf8Json
Stream

De UTF-8 Stream naar schrijven.

value
Object

De waarde die moet worden geconverteerd.

jsonTypeInfo
JsonTypeInfo

Metagegevens over het type dat moet worden geconverteerd.

Uitzonderingen

utf8Json is null.

value komt niet overeen met het type jsonTypeInfo.

Van toepassing op

Serialize(Object, Type, JsonSerializerOptions)

Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs

Converteert de waarde van een opgegeven type naar een JSON-tekenreeks.

[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

Parameters

value
Object

De waarde die moet worden geconverteerd.

inputType
Type

Het type dat value u wilt converteren.

options
JsonSerializerOptions

Opties voor het beheren van het conversiegedrag.

Retouren

De JSON-tekenreeksweergave van de waarde.

Kenmerken

Uitzonderingen

inputType is niet compatibel met value.

inputType is null.

Er is geen compatibel JsonConverter voor inputType of de serialiseerbare leden.

Opmerkingen

Het gebruik van een String is niet zo efficiënt als het gebruik van UTF-8-codering, omdat de implementatie intern gebruikmaakt van UTF-8. Zie ook SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) en SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken).

Zie JSON serialiseren en deserialiseren voor meer informatie.

Van toepassing op

Serialize(Object, Type, JsonSerializerContext)

Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs

Converteert de opgegeven waarde naar een 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

Parameters

value
Object

De waarde die moet worden geconverteerd.

inputType
Type

Het type dat value u wilt converteren.

context
JsonSerializerContext

Een metagegevensprovider voor serialiseerbare typen.

Retouren

Een String weergave van de waarde.

Uitzonderingen

Er is geen compatibel JsonConverter voor inputType of de serialiseerbare leden.

De GetTypeInfo(Type) opgegeven context methode retourneert null het type dat moet worden geconverteerd.

inputType of context is null.

Opmerkingen

Het gebruik van een String is niet zo efficiënt als het gebruik van UTF-8-codering, omdat de implementatie intern gebruikmaakt van UTF-8. SerializeToUtf8Bytes(Object, Type, JsonSerializerContext) Zie enSerializeAsync(Stream, Object, Type, JsonSerializerContext, CancellationToken).

Van toepassing op

Serialize(Utf8JsonWriter, Object, JsonTypeInfo)

Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs

Hiermee schrijft u één JSON-waarde (inclusief objecten of matrices) naar de opgegeven schrijver.

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)

Parameters

writer
Utf8JsonWriter

De schrijver die moet schrijven.

value
Object

De waarde die moet worden geconverteerd en geschreven.

jsonTypeInfo
JsonTypeInfo

Metagegevens over het type dat moet worden geconverteerd.

Uitzonderingen

writer of jsonTypeInfo is null.

value komt niet overeen met het type jsonTypeInfo.

Van toepassing op

Serialize(Stream, Object, Type, JsonSerializerOptions)

Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

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

Parameters

utf8Json
Stream

De UTF-8 Stream naar schrijven.

value
Object

De waarde die moet worden geconverteerd.

inputType
Type

Het type dat value u wilt converteren.

options
JsonSerializerOptions

Opties voor het beheren van het conversiegedrag.

Kenmerken

Uitzonderingen

inputType is niet compatibel met value.

utf8Json of inputType is null.

Er is geen compatibel JsonConverter voor inputType of de serialiseerbare leden.

Van toepassing op

Serialize(Stream, Object, Type, JsonSerializerContext)

Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

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)

Parameters

utf8Json
Stream

De UTF-8 Stream naar schrijven.

value
Object

De waarde die moet worden geconverteerd.

inputType
Type

Het type dat value u wilt converteren.

context
JsonSerializerContext

Een metagegevensprovider voor serialiseerbare typen.

Uitzonderingen

inputType is niet compatibel met value.

utf8Json, inputTypeof context is null.

Er is geen compatibel JsonConverter voor inputType of de serialiseerbare leden.

Van toepassing op

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions)

Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs

Hiermee schrijft u de JSON-weergave van het opgegeven type naar de opgegeven schrijver.

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

Parameters

writer
Utf8JsonWriter

De JSON-schrijver naar schrijven.

value
Object

De waarde die moet worden geconverteerd en geschreven.

inputType
Type

Het type dat value u wilt converteren.

options
JsonSerializerOptions

Opties voor het beheren van serialisatiegedrag.

Kenmerken

Uitzonderingen

inputType is niet compatibel met value

writer of inputType is null.

Er is geen compatibel JsonConverter voor inputType of de serialiseerbare leden.

Opmerkingen

De JsonWriterOptions functie voor het maken van het exemplaar van de Utf8JsonWriter instantie heeft voorrang op het JsonSerializerOptions moment dat ze conflicteren. JsonWriterOptions.Indented JsonWriterOptions.SkipValidationDaarom worden, en JsonWriterOptions.Encoder worden gebruikt tijdens het schrijven.

Zie JSON serialiseren en deserialiseren voor meer informatie.

Van toepassing op

Serialize(Utf8JsonWriter, Object, Type, JsonSerializerContext)

Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs

Hiermee schrijft u één JSON-waarde (inclusief objecten of matrices) naar de opgegeven schrijver.

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)

Parameters

writer
Utf8JsonWriter

Een JSON-schrijver naar schrijven.

value
Object

De waarde die moet worden geconverteerd en geschreven.

inputType
Type

Het type dat value u wilt converteren.

context
JsonSerializerContext

Een metagegevensprovider voor serialiseerbare typen.

Uitzonderingen

inputType is niet compatibel met value.

writer of inputType is null.

Er is geen compatibel JsonConverter voor inputType of de serialiseerbare leden.

De GetTypeInfo(Type) opgegeven context methode retourneert null het type dat moet worden geconverteerd.

Van toepassing op

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

Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs

Hiermee schrijft u één JSON-waarde (inclusief objecten of matrices) naar de opgegeven schrijver.

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

Type parameters

TValue

Het type van de waarde dat moet worden geserialiseerd.

Parameters

writer
Utf8JsonWriter

De schrijver die moet schrijven.

value
TValue

De waarde die moet worden geconverteerd en geschreven.

jsonTypeInfo
JsonTypeInfo<TValue>

Metagegevens over het type dat moet worden geconverteerd.

Uitzonderingen

writer of jsonTypeInfo is null.

Er is geen compatibel JsonConverter voor TValue of de serialiseerbare leden.

Van toepassing op

Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions)

Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs
Bron:
JsonSerializer.Write.Utf8JsonWriter.cs

Hiermee schrijft u de JSON-weergave van een type dat is opgegeven door een algemene typeparameter naar de opgegeven schrijver.

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

Type parameters

TValue

Het type van de waarde dat moet worden geserialiseerd.

Parameters

writer
Utf8JsonWriter

Een JSON-schrijver naar schrijven.

value
TValue

De waarde die moet worden geconverteerd en geschreven.

options
JsonSerializerOptions

Opties voor het beheren van serialisatiegedrag.

Kenmerken

Uitzonderingen

writer is null.

Er is geen compatibel JsonConverter voor TValue of de serialiseerbare leden.

Opmerkingen

De JsonWriterOptions functie voor het maken van het exemplaar van de Utf8JsonWriter instantie heeft voorrang op het JsonSerializerOptions moment dat ze conflicteren. JsonWriterOptions.Indented JsonWriterOptions.SkipValidationDaarom worden, en JsonWriterOptions.Encoder worden gebruikt tijdens het schrijven.

Zie JSON serialiseren en deserialiseren voor meer informatie.

Van toepassing op

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

Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

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

Type parameters

TValue

Het type van de waarde dat moet worden geserialiseerd.

Parameters

utf8Json
Stream

De UTF-8 Stream naar schrijven.

value
TValue

De waarde die moet worden geconverteerd.

jsonTypeInfo
JsonTypeInfo<TValue>

Metagegevens over het type dat moet worden geconverteerd.

Uitzonderingen

utf8Json is null.

Er is geen compatibel JsonConverter voor TValue of de serialiseerbare leden.

Van toepassing op

Serialize<TValue>(TValue, JsonSerializerOptions)

Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs

Converteert de waarde van een type dat is opgegeven door een algemene typeparameter naar een JSON-tekenreeks.

[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

Type parameters

TValue

Het type van de waarde dat moet worden geserialiseerd.

Parameters

value
TValue

De waarde die moet worden geconverteerd.

options
JsonSerializerOptions

Opties voor het beheren van serialisatiegedrag.

Retouren

Een JSON-tekenreeksweergave van de waarde.

Kenmerken

Uitzonderingen

Er is geen compatibel JsonConverter voor TValue of de serialiseerbare leden.

Opmerkingen

Het gebruik van een String is niet zo efficiënt als het gebruik van UTF-8-codering, omdat de implementatie intern gebruikmaakt van UTF-8. Zie ook SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) en SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken).

Zie JSON serialiseren en deserialiseren voor meer informatie.

Van toepassing op

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

Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs
Bron:
JsonSerializer.Write.String.cs

Converteert de opgegeven waarde naar een 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

Type parameters

TValue

Het type van de waarde dat moet worden geserialiseerd.

Parameters

value
TValue

De waarde die moet worden geconverteerd.

jsonTypeInfo
JsonTypeInfo<TValue>

Metagegevens over het type dat moet worden geconverteerd.

Retouren

Een String weergave van de waarde.

Uitzonderingen

Er is geen compatibel JsonConverter voor TValue of de serialiseerbare leden.

jsonTypeInfo is null.

Opmerkingen

Het gebruik van een String is niet zo efficiënt als het gebruik van UTF-8-codering, omdat de implementatie intern gebruikmaakt van UTF-8. Zie ook SerializeToUtf8Bytes<TValue>(TValue, JsonTypeInfo<TValue>) en SerializeAsync<TValue>(Stream, TValue, JsonTypeInfo<TValue>, CancellationToken).

Van toepassing op

Serialize<TValue>(Stream, TValue, JsonSerializerOptions)

Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs
Bron:
JsonSerializer.Write.Stream.cs

Converteert de opgegeven waarde naar met UTF-8 gecodeerde JSON-tekst en schrijft deze naar de Stream.

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

Type parameters

TValue

Het type van de waarde dat moet worden geserialiseerd.

Parameters

utf8Json
Stream

De UTF-8 Stream naar schrijven.

value
TValue

De waarde die moet worden geconverteerd.

options
JsonSerializerOptions

Opties voor het beheren van het conversiegedrag.

Kenmerken

Uitzonderingen

utf8Json is null.

Er is geen compatibel JsonConverter voor TValue of de serialiseerbare leden.

Van toepassing op