JsonSerializer.SerializeToDocument Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Överlagringar
| Name | Description |
|---|---|
| SerializeToDocument(Object, JsonTypeInfo) |
Konverterar det angivna värdet till en JsonDocument. |
| SerializeToDocument(Object, Type, JsonSerializerOptions) |
Konverterar det angivna värdet till en JsonDocument. |
| SerializeToDocument(Object, Type, JsonSerializerContext) |
Konverterar det angivna värdet till en JsonDocument. |
| SerializeToDocument<TValue>(TValue, JsonSerializerOptions) |
Konverterar det angivna värdet till en JsonDocument. |
| SerializeToDocument<TValue>(TValue, JsonTypeInfo<TValue>) |
Konverterar det angivna värdet till en JsonDocument. |
SerializeToDocument(Object, JsonTypeInfo)
Konverterar det angivna värdet till en JsonDocument.
public:
static System::Text::Json::JsonDocument ^ SerializeToDocument(System::Object ^ value, System::Text::Json::Serialization::Metadata::JsonTypeInfo ^ jsonTypeInfo);
public static System.Text.Json.JsonDocument SerializeToDocument(object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo jsonTypeInfo);
static member SerializeToDocument : obj * System.Text.Json.Serialization.Metadata.JsonTypeInfo -> System.Text.Json.JsonDocument
Public Function SerializeToDocument (value As Object, jsonTypeInfo As JsonTypeInfo) As JsonDocument
Parametrar
- value
- Object
Värdet som ska konverteras.
- jsonTypeInfo
- JsonTypeInfo
Metadata om vilken typ som ska konverteras.
Returer
En JsonDocument representation av värdet.
Undantag
jsonTypeInfo är null.
value matchar inte typen av jsonTypeInfo.
Gäller för
SerializeToDocument(Object, Type, JsonSerializerOptions)
Konverterar det angivna värdet till en JsonDocument.
[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 System.Text.Json.JsonDocument SerializeToDocument(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 System.Text.Json.JsonDocument SerializeToDocument(object? value, Type inputType, System.Text.Json.JsonSerializerOptions? options = default);
public static System.Text.Json.JsonDocument SerializeToDocument(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 SerializeToDocument : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
[<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 SerializeToDocument : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
static member SerializeToDocument : obj * Type * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
Public Function SerializeToDocument (value As Object, inputType As Type, Optional options As JsonSerializerOptions = Nothing) As JsonDocument
Parametrar
- value
- Object
Värdet som ska konverteras.
- inputType
- Type
Typ av att value konvertera.
- options
- JsonSerializerOptions
Alternativ för att styra konverteringsbeteendet.
Returer
En JsonDocument representation av värdet.
- Attribut
Undantag
inputType är inte kompatibelt med value.
inputType är null.
Det finns inga kompatibla JsonConverter för inputType eller dess serialiserbara medlemmar.
Gäller för
SerializeToDocument(Object, Type, JsonSerializerContext)
Konverterar det angivna värdet till en JsonDocument.
public:
static System::Text::Json::JsonDocument ^ SerializeToDocument(System::Object ^ value, Type ^ inputType, System::Text::Json::Serialization::JsonSerializerContext ^ context);
public static System.Text.Json.JsonDocument SerializeToDocument(object? value, Type inputType, System.Text.Json.Serialization.JsonSerializerContext context);
static member SerializeToDocument : obj * Type * System.Text.Json.Serialization.JsonSerializerContext -> System.Text.Json.JsonDocument
Public Function SerializeToDocument (value As Object, inputType As Type, context As JsonSerializerContext) As JsonDocument
Parametrar
- value
- Object
Värdet som ska konverteras.
- inputType
- Type
Typ av att value konvertera.
- context
- JsonSerializerContext
En metadataprovider för serialiserbara typer.
Returer
En JsonDocument representation av värdet.
Undantag
Det finns inga kompatibla JsonConverter för inputType eller dess serialiserbara medlemmar.
Metoden GetTypeInfo(Type) för de angivna context returnerar null för den typ som ska konverteras.
inputType eller context är null.
Gäller för
SerializeToDocument<TValue>(TValue, JsonSerializerOptions)
Konverterar det angivna värdet till en JsonDocument.
[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 System.Text.Json.JsonDocument SerializeToDocument<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 System.Text.Json.JsonDocument SerializeToDocument<TValue>(TValue value, System.Text.Json.JsonSerializerOptions? options = default);
public static System.Text.Json.JsonDocument SerializeToDocument<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 SerializeToDocument : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
[<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 SerializeToDocument : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
static member SerializeToDocument : 'Value * System.Text.Json.JsonSerializerOptions -> System.Text.Json.JsonDocument
Public Function SerializeToDocument(Of TValue) (value As TValue, Optional options As JsonSerializerOptions = Nothing) As JsonDocument
Typparametrar
- TValue
Typ av värde som ska serialiseras.
Parametrar
- value
- TValue
Värdet som ska konverteras.
- options
- JsonSerializerOptions
Alternativ för att styra konverteringsbeteendet.
Returer
En JsonDocument representation av JSON-värdet.
- Attribut
Undantag
Det finns inga kompatibla JsonConverter för TValue eller dess serialiserbara medlemmar.
Gäller för
SerializeToDocument<TValue>(TValue, JsonTypeInfo<TValue>)
Konverterar det angivna värdet till en JsonDocument.
public:
generic <typename TValue>
static System::Text::Json::JsonDocument ^ SerializeToDocument(TValue value, System::Text::Json::Serialization::Metadata::JsonTypeInfo<TValue> ^ jsonTypeInfo);
public static System.Text.Json.JsonDocument SerializeToDocument<TValue>(TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo);
static member SerializeToDocument : 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> -> System.Text.Json.JsonDocument
Public Function SerializeToDocument(Of TValue) (value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue)) As JsonDocument
Typparametrar
- TValue
Typ av värde som ska serialiseras.
Parametrar
- value
- TValue
Värdet som ska konverteras.
- jsonTypeInfo
- JsonTypeInfo<TValue>
Metadata om vilken typ som ska konverteras.
Returer
En JsonDocument representation av värdet.
Undantag
Det finns inga kompatibla JsonConverter för TValue eller dess serialiserbara medlemmar.
jsonTypeInfo är null.