JsonSerializer.Deserialize Yöntem
Tanım
Aşırı Yüklemeler
| Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerOptions) |
Tek bir JSON değerini belirtilen tür örneğine gösteren UTF-8 kodlu metni ayrıştırır.Parses the UTF-8 encoded text representing a single JSON value into an instance of a specified type. |
| Deserialize(String, Type, JsonSerializerOptions) |
Tek bir JSON değerini temsil eden metni belirtilen bir türün örneğine ayrıştırır.Parses the text representing a single JSON value into an instance of a specified type. |
| Deserialize(Utf8JsonReader, Type, JsonSerializerOptions) |
Belirtilen okuyucudan bir JSON değeri (nesneler veya diziler dahil) okur ve onu belirtilen türden bir örneğe dönüştürür.Reads one JSON value (including objects or arrays) from the provided reader and converts it into an instance of a specified type. |
| Deserialize<TValue>(ReadOnlySpan<Byte>, JsonSerializerOptions) |
Tek bir JSON değerini temsil eden UTF-8 kodlu metni, genel tür parametresiyle belirtilen tür örneğine ayrıştırır.Parses the UTF-8 encoded text representing a single JSON value into an instance of the type specified by a generic type parameter. |
| Deserialize<TValue>(String, JsonSerializerOptions) |
Tek bir JSON değerini temsil eden metni, genel tür parametresiyle belirtilen tür örneğine ayrıştırır.Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter. |
| Deserialize<TValue>(Utf8JsonReader, JsonSerializerOptions) |
Belirtilen okuyucudan bir JSON değeri (nesneler veya diziler dahil) bir genel tür parametresi tarafından belirtilen türün örneğine okur.Reads one JSON value (including objects or arrays) from the provided reader into an instance of the type specified by a generic type parameter. |
Deserialize(ReadOnlySpan<Byte>, Type, JsonSerializerOptions)
Tek bir JSON değerini belirtilen tür örneğine gösteren UTF-8 kodlu metni ayrıştırır.Parses the UTF-8 encoded text representing a single JSON value into an instance of a specified type.
public static object? Deserialize (ReadOnlySpan<byte> utf8Json, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
public static object Deserialize (ReadOnlySpan<byte> utf8Json, Type returnType, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : ReadOnlySpan<byte> * Type * System.Text.Json.JsonSerializerOptions -> obj
Public Shared Function Deserialize (utf8Json As ReadOnlySpan(Of Byte), returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object
Parametreler
- utf8Json
- ReadOnlySpan<Byte>
Çözümlenecek JSON metni.The JSON text to parse.
- returnType
- Type
Dönüştürülecek ve döndürülecek nesnenin türü.The type of the object to convert to and return.
- options
- JsonSerializerOptions
Ayrıştırma sırasında davranışı denetleme seçenekleri.Options to control the behavior during parsing.
Döndürülenler
returnTypeJSON değerinin temsili.A returnType representation of the JSON value.
Özel durumlar
returnType, null değeridir.returnType is null.
JSON geçersiz.The JSON is invalid.
-veya--or-
returnType JSON ile uyumlu değil.returnType is not compatible with the JSON.
-veya--or-
Yayılma alanında tek bir JSON değerinin ötesinde kalan veriler var.There is remaining data in the span beyond a single JSON value.
JsonConverter returnType Veya seri hale getirilebilir üyeleri için uyumlu değildir.There is no compatible JsonConverter for returnType or its serializable members.
Açıklamalar
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
Deserialize(String, Type, JsonSerializerOptions)
Tek bir JSON değerini temsil eden metni belirtilen bir türün örneğine ayrıştırır.Parses the text representing a single JSON value into an instance of a specified type.
public static object? Deserialize (string json, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
public static object Deserialize (string json, Type returnType, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : string * Type * System.Text.Json.JsonSerializerOptions -> obj
Public Shared Function Deserialize (json As String, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object
Parametreler
- json
- String
Çözümlenecek JSON metni.The JSON text to parse.
- returnType
- Type
Dönüştürülecek ve döndürülecek nesnenin türü.The type of the object to convert to and return.
- options
- JsonSerializerOptions
Ayrıştırma sırasında davranışı denetleme seçenekleri.Options to control the behavior during parsing.
Döndürülenler
returnTypeJSON değerinin temsili.A returnType representation of the JSON value.
Özel durumlar
json ya returnType da null .json or returnType is null.
JSON geçersiz.The JSON is invalid.
-veya--or-
TValue JSON ile uyumlu değil.TValue is not compatible with the JSON.
-veya--or-
Dizedeki tek bir JSON değerinin ötesinde kalan veriler var.There is remaining data in the string beyond a single JSON value.
JsonConverter returnType Veya seri hale getirilebilir üyeleri için uyumlu değildir.There is no compatible JsonConverter for returnType or its serializable members.
Açıklamalar
StringUygulama yerel olarak UTF-8 kullandığından, bir, UTF-8 yöntemlerini kullanmak kadar verimli değildir.Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.
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
Deserialize(Utf8JsonReader, Type, JsonSerializerOptions)
Belirtilen okuyucudan bir JSON değeri (nesneler veya diziler dahil) okur ve onu belirtilen türden bir örneğe dönüştürür.Reads one JSON value (including objects or arrays) from the provided reader and converts it into an instance of a specified type.
public static object? Deserialize (ref System.Text.Json.Utf8JsonReader? reader, Type returnType, System.Text.Json.JsonSerializerOptions? options = default);
public static object Deserialize (ref System.Text.Json.Utf8JsonReader reader, Type returnType, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : Utf8JsonReader * Type * System.Text.Json.JsonSerializerOptions -> obj
Public Shared Function Deserialize (ByRef reader As Utf8JsonReader, returnType As Type, Optional options As JsonSerializerOptions = Nothing) As Object
Parametreler
- reader
- Utf8JsonReader
JSON 'dan okunan okuyucu.The reader to read the JSON from.
- returnType
- Type
Dönüştürülecek ve döndürülecek nesnenin türü.The type of the object to convert to and return.
- options
- JsonSerializerOptions
Okuma sırasında serileştirici davranışını denetleme seçenekleri.Options to control the serializer behavior during reading.
Döndürülenler
returnTypeJSON değerinin temsili.A returnType representation of the JSON value.
Özel durumlar
returnType, null değeridir.returnType is null.
JSON geçersiz.The JSON is invalid.
-veya--or-
returnType JSON ile uyumlu değil.returnType is not compatible with the JSON.
-veya--or-
Okuyucudan bir değer okunamadı.A value could not be read from the reader.
reader , desteklenmeyen seçenekler kullanıyor.reader is using unsupported options.
JsonConverter returnType Veya seri hale getirilebilir üyeleri için uyumlu değildir.There is no compatible JsonConverter for returnType or its serializable members.
Açıklamalar
TokenTypeÖzelliği reader JsonTokenType.PropertyName veya ise JsonTokenType.None , okuyucu değerin başlangıcını belirlemede bir çağrısıyla ilerlecektir Utf8JsonReader.Read() .If the TokenType property of reader is JsonTokenType.PropertyName or JsonTokenType.None, the reader will be advanced by one call to Utf8JsonReader.Read() to determine the start of the value.
Bu yöntemin tamamlanmasından sonra, reader JSON değerindeki son belirtece konumlandırılacaktır.Upon completion of this method, reader will be positioned at the final token in the JSON value. Bir özel durum oluşturulursa, okuyucu yöntemi çağrıldığında bulunduğu duruma sıfırlanır.If an exception is thrown, the reader is reset to the state it was in when the method was called.
Bu yöntem, okuyucunun üzerinde işlem yaptığı verilerin bir kopyasını oluşturur, bu nedenle bu yöntemin geri dönmesi ötesinde veri bütünlüğünü sürdürmek için bir arayan gereksinimi yoktur.This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.
JsonReaderOptionsÖğesinin örneğini oluşturmak için kullanılan, Utf8JsonReader Çakışma sırasında üzerine öncelik alır JsonSerializerOptions .The JsonReaderOptions used to create the instance of the Utf8JsonReader take precedence over the JsonSerializerOptions when they conflict. Bu nedenle,, JsonReaderOptions.AllowTrailingCommas JsonReaderOptions.MaxDepth ve JsonReaderOptions.CommentHandling okunurken kullanılır.Hence, JsonReaderOptions.AllowTrailingCommas, JsonReaderOptions.MaxDepth, and JsonReaderOptions.CommentHandling are used while reading.
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
Deserialize<TValue>(ReadOnlySpan<Byte>, JsonSerializerOptions)
Tek bir JSON değerini temsil eden UTF-8 kodlu metni, genel tür parametresiyle belirtilen tür örneğine ayrıştırır.Parses the UTF-8 encoded text representing a single JSON value into an instance of the type specified by a generic type parameter.
public static TValue? Deserialize<TValue> (ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions? options = default);
public static TValue Deserialize<TValue> (ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : ReadOnlySpan<byte> * System.Text.Json.JsonSerializerOptions -> 'Value
Public Shared Function Deserialize(Of TValue) (utf8Json As ReadOnlySpan(Of Byte), Optional options As JsonSerializerOptions = Nothing) As TValue
Tür Parametreleri
- TValue
UTF-8 ile kodlanmış metnin hedef türü.The target type of the UTF-8 encoded text.
Parametreler
- utf8Json
- ReadOnlySpan<Byte>
Çözümlenecek JSON metni.The JSON text to parse.
- options
- JsonSerializerOptions
Ayrıştırma sırasında davranışı denetleme seçenekleri.Options to control the behavior during parsing.
Döndürülenler
- TValue
TValueJSON değerinin temsili.A TValue representation of the JSON value.
Özel durumlar
JSON geçersiz.The JSON is invalid.
-veya--or-
TValue JSON ile uyumlu değil.TValue is not compatible with the JSON.
-veya--or-
Yayılma alanında tek bir JSON değerinin ötesinde kalan veriler var.There is remaining data in the span beyond a single JSON value.
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
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
Deserialize<TValue>(String, JsonSerializerOptions)
Tek bir JSON değerini temsil eden metni, genel tür parametresiyle belirtilen tür örneğine ayrıştırır.Parses the text representing a single JSON value into an instance of the type specified by a generic type parameter.
public static TValue? Deserialize<TValue> (string json, System.Text.Json.JsonSerializerOptions? options = default);
public static TValue Deserialize<TValue> (string json, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : string * System.Text.Json.JsonSerializerOptions -> 'Value
Public Shared Function Deserialize(Of TValue) (json As String, Optional options As JsonSerializerOptions = Nothing) As TValue
Tür Parametreleri
- TValue
JSON değerinin hedef türü.The target type of the JSON value.
Parametreler
- json
- String
Çözümlenecek JSON metni.The JSON text to parse.
- options
- JsonSerializerOptions
Ayrıştırma sırasında davranışı denetleme seçenekleri.Options to control the behavior during parsing.
Döndürülenler
- TValue
TValueJSON değerinin temsili.A TValue representation of the JSON value.
Özel durumlar
json, null değeridir.json is null.
JSON geçersiz.The JSON is invalid.
-veya--or-
TValue JSON ile uyumlu değil.TValue is not compatible with the JSON.
-veya--or-
Dizedeki tek bir JSON değerinin ötesinde kalan veriler var.There is remaining data in the string beyond a single JSON value.
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 yerel olarak UTF-8 kullandığından, bir, UTF-8 yöntemlerini kullanmak kadar verimli değildir.Using a String is not as efficient as using the UTF-8 methods since the implementation natively uses UTF-8.
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
Deserialize<TValue>(Utf8JsonReader, JsonSerializerOptions)
Belirtilen okuyucudan bir JSON değeri (nesneler veya diziler dahil) bir genel tür parametresi tarafından belirtilen türün örneğine okur.Reads one JSON value (including objects or arrays) from the provided reader into an instance of the type specified by a generic type parameter.
public static TValue? Deserialize<TValue> (ref System.Text.Json.Utf8JsonReader? reader, System.Text.Json.JsonSerializerOptions? options = default);
public static TValue Deserialize<TValue> (ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options = default);
static member Deserialize : Utf8JsonReader * System.Text.Json.JsonSerializerOptions -> 'Value
Public Shared Function Deserialize(Of TValue) (ByRef reader As Utf8JsonReader, Optional options As JsonSerializerOptions = Nothing) As TValue
Tür Parametreleri
- TValue
JSON değerinin hedef türü.The target type of the JSON value.
Parametreler
- reader
- Utf8JsonReader
JSON 'dan okunan okuyucu.The reader to read the JSON from.
- options
- JsonSerializerOptions
Okuma sırasında serileştirici davranışını denetleme seçenekleri.Options to control serializer behavior during reading.
Döndürülenler
- TValue
TValueJSON değerinin temsili.A TValue representation of the JSON value.
Özel durumlar
JSON geçersiz.The JSON is invalid.
-veya--or-
TValue JSON ile uyumlu değil.TValue is not compatible with the JSON.
-veya--or-
Okuyucudan bir değer okunamadı.A value could not be read from the reader.
reader Desteklenmeyen seçenekleri kullanır.reader uses unsupported options.
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
TokenTypeÖzelliği reader JsonTokenType.PropertyName veya ise JsonTokenType.None , okuyucu değerin başlangıcını belirlemede bir çağrısıyla ilerlecektir Utf8JsonReader.Read() .If the TokenType property of reader is JsonTokenType.PropertyName or JsonTokenType.None, the reader will be advanced by one call to Utf8JsonReader.Read() to determine the start of the value.
Bu yöntemin tamamlanmasından sonra, reader JSON değerindeki son belirtece konumlandırılacaktır.Upon completion of this method, reader will be positioned at the final token in the JSON value. Bir özel durum oluşturulursa, okuyucu yöntemi çağrıldığında bulunduğu duruma sıfırlanır.If an exception is thrown, the reader is reset to the state it was in when the method was called.
Bu yöntem, okuyucunun üzerinde işlem yaptığı verilerin bir kopyasını oluşturur, bu nedenle bu yöntemin geri dönmesi ötesinde veri bütünlüğünü sürdürmek için bir arayan gereksinimi yoktur.This method makes a copy of the data the reader acted on, so there is no caller requirement to maintain data integrity beyond the return of this method.
JsonReaderOptionsÖğesinin örneğini oluşturmak için kullanılan, Utf8JsonReader Çakışma sırasında üzerine öncelik alır JsonSerializerOptions .The JsonReaderOptions used to create the instance of the Utf8JsonReader take precedence over the JsonSerializerOptions when they conflict. Bu nedenle,, JsonReaderOptions.AllowTrailingCommas JsonReaderOptions.MaxDepth ve JsonReaderOptions.CommentHandling okunurken kullanılır.Hence, JsonReaderOptions.AllowTrailingCommas, JsonReaderOptions.MaxDepth, and JsonReaderOptions.CommentHandling are used while reading.
Daha fazla bilgi için bkz. JSON serileştirme ve seri durumdan çıkarma.For more information, see How to serialize and deserialize JSON.