Class SystemJsonSerializer
- Namespace
- Akavache.System
Text Json
- Assembly
- Akavache.SystemTextJson.dll
A unified serializer using System.Text.Json with automatic format detection. Supports both JSON and BSON formats for maximum compatibility.
- Inheritance
-
System
Json Serializer
- Implements
- Derived
- Extension Methods
Constructors
SystemJsonSerializer()
Properties
ForcedDateTimeKind
Gets or sets the DateTimeKind handling for BSON readers to be forced.
Property Value
Remarks
By default, BsonReader uses a DateDateTimeKind, you can set this value.
Options
Gets or sets the JSON serializer options for customizing serialization behavior.
Property Value
UseBsonFormat
Gets or sets a value indicating whether to use BSON format for serialization. When true, serializes to BSON for maximum Akavache compatibility. When false (default), serializes to JSON for better performance.
Property Value
Methods
Deserialize<T>(byte[])
Deserializes from bytes.
[RequiresUnreferencedCode("Using System.Text.Json requires types to be preserved for deserialization.")]
[RequiresDynamicCode("Using System.Text.Json requires types to be preserved for deserialization.")]
public T? Deserialize<T>(byte[] bytes)
Parameters
bytesbyte[]The bytes.
Returns
- T
The type.
Type Parameters
TThe type to deserialize to.
IsPotentialBsonData(byte[])
Checks if data might be BSON format.
Parameters
databyte[]The data to check.
Returns
- bool
True if data might be BSON.
Serialize<T>(T)
Serializes to an bytes.
[RequiresUnreferencedCode("Using System.Text.Json requires types to be preserved for serialization.")]
[RequiresDynamicCode("Using System.Text.Json requires types to be preserved for serialization.")]
public byte[] Serialize<T>(T item)
Parameters
itemTThe item to serialize.
Returns
- byte[]
The bytes.
Type Parameters
TThe type of serialize.