JsonSerializer.Serialize Yöntem
Tanım
Aşırı Yüklemeler
| Serialize(Object, Type, JsonSerializerOptions) |
Belirtilen türdeki değeri JSON dizesine dönüştürür.Converts the value of a specified type into a JSON string. |
| Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions) |
Belirtilen türdeki JSON gösterimini belirtilen yazıcıya yazar.Writes the JSON representation of the specified type to the provided writer. |
| Serialize<TValue>(TValue, JsonSerializerOptions) |
Genel tür parametresiyle belirtilen bir türün değerini bir JSON dizesine dönüştürür.Converts the value of a type specified by a generic type parameter into a JSON string. |
| Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions) |
Bir genel tür parametresi tarafından belirtilen bir türün JSON temsilini belirtilen yazıcıya yazar.Writes the JSON representation of a type specified by a generic type parameter to the provided writer. |
Serialize(Object, Type, JsonSerializerOptions)
Belirtilen türdeki değeri JSON dizesine dönüştürür.Converts the value of a specified type into a JSON string.
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);
static member Serialize : obj * Type * System.Text.Json.JsonSerializerOptions -> string
Public Shared Function Serialize (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As String
Parametreler
- value
- Object
Dönüştürülecek değer.The value to convert.
- inputType
- Type
Dönüştürülecek öğesinin türü value .The type of the value to convert.
- options
- JsonSerializerOptions
Dönüştürme davranışını denetleme seçenekleri.Options to control the conversion behavior.
Döndürülenler
Değerin JSON dize temsili.The JSON string representation of the value.
Özel durumlar
inputType ile uyumlu değildir value .inputType is not compatible with value.
inputType, null değeridir.inputType is null.
JsonConverter inputType Veya seri hale getirilebilir üyeleri için uyumlu değildir.There is no compatible JsonConverter for inputType or its serializable members.
Açıklamalar
StringUygulama dahili olarak UTF-8 kullandığından, bir kullanmak UTF-8 kodlaması kullanmak kadar verimli değildir.Using a String is not as efficient as using UTF-8 encoding since the implementation internally uses UTF-8. Ayrıca bkz SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken) . ve.See also SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) and SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken).
Daha fazla bilgi için bkz. JSON serileştirme ve seri durumdan çıkarma.For more information, see How to serialize and deserialize JSON.
Şunlara uygulanır
Serialize(Utf8JsonWriter, Object, Type, JsonSerializerOptions)
Belirtilen türdeki JSON gösterimini belirtilen yazıcıya yazar.Writes the JSON representation of the specified type to the provided writer.
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);
static member Serialize : System.Text.Json.Utf8JsonWriter * obj * Type * System.Text.Json.JsonSerializerOptions -> unit
Public Shared Sub Serialize (writer As Utf8JsonWriter, value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing)
Parametreler
- writer
- Utf8JsonWriter
Yazılacak JSON yazıcı.The JSON writer to write to.
- value
- Object
Dönüştürülecek ve yazılacak değer.The value to convert and write.
- inputType
- Type
Dönüştürülecek öğesinin türü value .The type of the value to convert.
- options
- JsonSerializerOptions
Serileştirme davranışını denetleme seçenekleri.Options to control serialization behavior.
Özel durumlar
inputType ile uyumlu değil valueinputType is not compatible with value
writer ya inputType da null .writer or inputType is null.
JsonConverter inputType Veya seri hale getirilebilir üyeleri için uyumlu değildir.There is no compatible JsonConverter for inputType or its serializable members.
Açıklamalar
JsonWriterOptionsÖğesinin örneğini oluşturmak için kullanılan, Utf8JsonWriter Çakışma sırasında üzerine öncelik alır JsonSerializerOptions .The JsonWriterOptions used to create the instance of the Utf8JsonWriter take precedence over the JsonSerializerOptions when they conflict. Bu nedenle,, JsonWriterOptions.Indented JsonWriterOptions.SkipValidation ve JsonWriterOptions.Encoder yazma sırasında kullanılır.Hence, JsonWriterOptions.Indented, JsonWriterOptions.SkipValidation, and JsonWriterOptions.Encoder are used while writing.
Daha fazla bilgi için bkz. JSON serileştirme ve seri durumdan çıkarma.For more information, see How to serialize and deserialize JSON.
Şunlara uygulanır
Serialize<TValue>(TValue, JsonSerializerOptions)
Genel tür parametresiyle belirtilen bir türün değerini bir JSON dizesine dönüştürür.Converts the value of a type specified by a generic type parameter into a JSON string.
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);
static member Serialize : 'Value * System.Text.Json.JsonSerializerOptions -> string
Public Shared Function Serialize(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As String
Tür Parametreleri
- TValue
Seri hale getirilecek değerin türü.The type of the value to serialize.
Parametreler
- value
- TValue
Dönüştürülecek değer.The value to convert.
- options
- JsonSerializerOptions
Serileştirme davranışını denetleme seçenekleri.Options to control serialization behavior.
Döndürülenler
Değerin JSON dize temsili.A JSON string representation of the value.
Özel durumlar
JsonConverter TValue Veya seri hale getirilebilir üyeleri için uyumlu değildir.There is no compatible JsonConverter for TValue or its serializable members.
Açıklamalar
StringUygulama dahili olarak UTF-8 kullandığından, bir kullanmak UTF-8 kodlaması kullanmak kadar verimli değildir.Using a String is not as efficient as using UTF-8 encoding since the implementation internally uses UTF-8. Ayrıca bkz SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken) . ve.See also SerializeToUtf8Bytes(Object, Type, JsonSerializerOptions) and SerializeAsync(Stream, Object, Type, JsonSerializerOptions, CancellationToken).
Daha fazla bilgi için bkz. JSON serileştirme ve seri durumdan çıkarma.For more information, see How to serialize and deserialize JSON.
Şunlara uygulanır
Serialize<TValue>(Utf8JsonWriter, TValue, JsonSerializerOptions)
Bir genel tür parametresi tarafından belirtilen bir türün JSON temsilini belirtilen yazıcıya yazar.Writes the JSON representation of a type specified by a generic type parameter to the provided writer.
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);
static member Serialize : System.Text.Json.Utf8JsonWriter * 'Value * System.Text.Json.JsonSerializerOptions -> unit
Public Shared Sub Serialize(Of TValue) (writer As Utf8JsonWriter, value As TValue, Optional options As JsonSerializerOptions = Nothing)
Tür Parametreleri
- TValue
Seri hale getirilecek değerin türü.The type of the value to serialize.
Parametreler
- writer
- Utf8JsonWriter
Yazılacak bir JSON yazıcı.A JSON writer to write to.
- value
- TValue
Dönüştürülecek ve yazılacak değer.The value to convert and write.
- options
- JsonSerializerOptions
Serileştirme davranışını denetleme seçenekleri.Options to control serialization behavior.
Özel durumlar
writer, null değeridir.writer is null.
JsonConverter TValue Veya seri hale getirilebilir üyeleri için uyumlu değildir.There is no compatible JsonConverter for TValue or its serializable members.
Açıklamalar
JsonWriterOptionsÖğesinin örneğini oluşturmak için kullanılan, Utf8JsonWriter Çakışma sırasında üzerine öncelik alır JsonSerializerOptions .The JsonWriterOptions used to create the instance of the Utf8JsonWriter take precedence over the JsonSerializerOptions when they conflict. Bu nedenle,, JsonWriterOptions.Indented JsonWriterOptions.SkipValidation ve JsonWriterOptions.Encoder yazma sırasında kullanılır.Hence, JsonWriterOptions.Indented, JsonWriterOptions.SkipValidation, and JsonWriterOptions.Encoder are used while writing.
Daha fazla bilgi için bkz. JSON serileştirme ve seri durumdan çıkarma.For more information, see How to serialize and deserialize JSON.