Table of Contents

Class JsonCompressedStreamSerialization

Namespace
Arc4u.Serializer
Assembly
Arc4u.Serializer.JSon.dll

Base class of Json serialization based on compressed streams.

public abstract class JsonCompressedStreamSerialization : JsonCompressedStreamSerializationBase, IObjectSerialization
Inheritance
JsonCompressedStreamSerialization
Implements
Derived
Inherited Members

Constructors

JsonCompressedStreamSerialization()

Construct with default options

[RequiresUnreferencedCode("This constructor is not suitable for AOT. Use the constructor with JsonSerializerContext for AOT compatibility.")]
protected JsonCompressedStreamSerialization()

JsonCompressedStreamSerialization(JsonSerializerOptions)

Construct an instance, optionally specifying compression and other Json serializer options

[RequiresUnreferencedCode("This constructor is not suitable for AOT. Use the constructor with JsonSerializerContext for AOT compatibility.")]
protected JsonCompressedStreamSerialization(JsonSerializerOptions options)

Parameters

options JsonSerializerOptions

Json serializer options

JsonCompressedStreamSerialization(JsonSerializerContext)

Construct an instance, optionally specifying compression and a serialization context. This is used for source generation, implemented in .NET 6 or later (https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation?pivots=dotnet-6-0)

protected JsonCompressedStreamSerialization(JsonSerializerContext context)

Parameters

context JsonSerializerContext

Json context for source generation

Methods

CreateForCompression(Stream)

Wraps the stream in a compression stream. The underlying stream must be left open.

protected abstract Stream CreateForCompression(Stream stream)

Parameters

stream Stream

The stream that receives the compressed data.

Returns

Stream

The compression stream.

CreateForDecompression(Stream)

Wraps the stream in a decompression stream.

protected abstract Stream CreateForDecompression(Stream stream)

Parameters

stream Stream

The stream that contains the compressed data.

Returns

Stream

The decompression stream.

Deserialize(byte[], Type)

Deserializes bytes to an object of a type known only at runtime.

public object? Deserialize(byte[] data, Type objectType)

Parameters

data byte[]

The serialized bytes.

objectType Type

The type of the object to create.

Returns

object

The deserialized object.

Deserialize<T>(byte[])

Deserializes bytes produced by Serialize<T>(T).

public T? Deserialize<T>(byte[] data)

Parameters

data byte[]

The serialized bytes.

Returns

T

The deserialized value.

Type Parameters

T

The expected type of the value.

Serialize<T>(T)

Serializes a value to bytes.

public byte[] Serialize<T>(T value)

Parameters

value T

The value to serialize.

Returns

byte[]

The serialized bytes.

Type Parameters

T

The type of the value.