JsonSerializer
Provides JSON serialization and deserialization for a given type.
Наследует: Serializer<T>
Реализует: IJsonSerializer
Свойства
public int BufferSize { get; set; }
value = jsonSerializer.BufferSize
jsonSerializer.BufferSize = value
Gets or sets the buffer size used during serialization and deserialization.
public Encoding Encoding { get; set; }
value = jsonSerializer.Encoding
jsonSerializer.Encoding = value
Gets or sets the text encoding used for serialization. Defaults to UTF8.
public bool EncryptedAsByteArray { get; set; }
value = jsonSerializer.EncryptedAsByteArray
jsonSerializer.EncryptedAsByteArray = value
Gets or sets a value indicating whether encrypted values are handled as byte arrays.
public bool EnumAsString { get; set; }
value = jsonSerializer.EnumAsString
jsonSerializer.EnumAsString = value
Gets or sets a value indicating whether enums should be serialized as strings.
public override string FileExtension { get; }
value = jsonSerializer.FileExtension
Gets the file extension associated with the JSON serializer.
public bool FillMode { get; set; }
value = jsonSerializer.FillMode
jsonSerializer.FillMode = value
Gets or sets a value indicating whether the fill mode is enabled.
public bool Indent { get; set; }
value = jsonSerializer.Indent
jsonSerializer.Indent = value
Gets or sets a value indicating whether the JSON output should be indented.
public NullValueHandling NullValueHandling { get; set; }
value = jsonSerializer.NullValueHandling
jsonSerializer.NullValueHandling = value
Gets or sets the null value handling option for JSON serialization.
public ISecureStringEncryptor SecureStringEncryptor { get; set; }
value = jsonSerializer.SecureStringEncryptor
jsonSerializer.SecureStringEncryptor = value
Gets or sets the local SecureString encryptor used by this serializer. When set, it overrides Encryptor only while this serializer is serializing or deserializing.
Методы
public static JsonSerializer<T> CreateDefault()
result = JsonSerializer.CreateDefault()
Creates a default instance of the JSON serializer with preconfigured settings.
Возвращает: A default JsonSerializer instance.
public override ValueTask<T> DeserializeAsync(Stream stream, CancellationToken cancellationToken)
result = jsonSerializer.DeserializeAsync(stream, cancellationToken)
Asynchronously deserializes an object graph from the provided JSON stream.
- stream
- The stream from which the object graph is deserialized.
- cancellationToken
- A token that can be used to cancel the deserialization operation.
Возвращает: A task representing the asynchronous deserialization operation. The task result contains the deserialized object graph.
public override ValueTask SerializeAsync(T graph, Stream stream, CancellationToken cancellationToken)
result = jsonSerializer.SerializeAsync(graph, stream, cancellationToken)
Asynchronously serializes the specified object graph to the provided stream as JSON.
- graph
- The object graph to serialize.
- stream
- The stream to which the graph is serialized.
- cancellationToken
- A token that can be used to cancel the serialization operation.
Возвращает: A task representing the asynchronous serialization operation.