Class ListSerializer<T>
Type serializer for List<T> collections. Serializes the list as a JSON array
token sequence (start-array, elements, end-array), or as a null token when the list
reference itself is null.
Inherited Members
Namespace: Scylla.Core.Util.Serialization
Assembly: ScyllaCore.dll
Syntax
public sealed class ListSerializer<T> : TypeSerializerBase<List<T>>, ITypeSerializer<List<T>>, ITypeSerializer
Type Parameters
| Name | Description |
|---|---|
| T | The element type of the list. Element serialization is handled either by the explicitly supplied ITypeSerializer or, by default, by per-call resolution through the active ISerializationContext and the global registry. |
Remarks
On read, elements are added to a List<T> instance with an initial default capacity; the list is returned directly without an array conversion step, unlike ArraySerializer<T>.
Comma handling between JSON elements is delegated to SkipComma() when the active reader is a ScyllaJSONReader.
Constructors
ListSerializer(ITypeSerializer)
Creates a list serializer that uses the specified serializer for each element.
Declaration
public ListSerializer(ITypeSerializer elementSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| ITypeSerializer | elementSerializer | The non-generic serializer to use for every list element, or |
Methods
Read(IScyllaReader, ISerializationContext)
Reads a List<T> from the reader.
Returns null when the next token is a null literal; otherwise reads all elements
from the array token sequence into a new List<T> and returns it.
Declaration
public override List<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 |
|---|---|
| List<T> | The deserialized list, or |
Overrides
Write(List<T>, IScyllaWriter, ISerializationContext)
Writes a List<T> to the output.
Emits a null token if value is null; otherwise emits a
JSON array containing all elements serialized in list order.
Declaration
public override void Write(List<T> value, IScyllaWriter writer, ISerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| List<T> | value | The list to serialize, or |
| IScyllaWriter | writer | The writer that receives the serialized output. Never |
| ISerializationContext | context | The active serialization context. Never |