Class ArraySerializer<T>
Type serializer for arrays of type T. Serializes the array as a
JSON array token sequence (start-array, elements, end-array), or as a null token when the
array reference itself is null.
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class ArraySerializer<T> : TypeSerializerBase<T[]>, ITypeSerializer<T[]>, ITypeSerializer
Type Parameters
| Name | Description |
|---|---|
| T | The element type of the array. The serializer resolves element serialization either via the explicitly supplied ITypeSerializer or, by default, by per-call resolution through the active ISerializationContext and the global registry. |
Remarks
On read, elements are accumulated into a temporary List<T> and then converted to an array via ToArray(), which involves a single allocation and copy. There is currently no fixed-capacity pre-allocation because the element count is not known before the end-array token is encountered.
Comma handling between JSON elements is delegated to SkipComma() when the active reader is a ScyllaJSONReader. Other reader implementations are expected to handle separators internally.
Constructors
ArraySerializer(ITypeSerializer)
Creates an array serializer that uses the specified serializer for each element.
Declaration
public ArraySerializer(ITypeSerializer elementSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| ITypeSerializer | elementSerializer | The non-generic serializer to use for every array element, or |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a T array from the reader.
Returns null when the next token is a null literal; otherwise reads all elements
from the array token sequence and returns them as a new array.
Declaration
public override T[] Read(IScyllaReader reader, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaReader | reader | The reader positioned at the start of an array token sequence or a null token.
Never |
| ISerializationContext | context | The active serialization context. Never |
Returns
| Type | Description |
|---|---|
| T[] | The deserialized array, or |
Overrides
Write(T[], IScyllaWriter, ISerializationContext)
Writes a T array to the output.
Emits a null token if value is null; otherwise emits a
JSON array containing all elements serialized in iteration order.
Declaration
public override void Write(T[] value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | value | The array to serialize, or |
| IScyllaWriter | writer | The writer that receives the serialized output. Never |
| ISerializationContext | context | The active serialization context. Never |