Table of Contents

Class SymbolsJsonConverter

Namespace
DatabentoDotNet.Historical.Json
Assembly
DatabentoDotNet.Historical.dll

Reads a Symbols from any of the four shapes the API sends one in, and writes it as the comma-joined string the API takes.

public sealed class SymbolsJsonConverter : JsonConverter<Symbols>
Inheritance
SymbolsJsonConverter
Inherited Members

Remarks

Port of upstream's hand-written Deserialize for Symbols (databento-rs/src/lib.rs:189-211), which tries an untagged helper in the order u32, Vec<u32>, String, Vec<String>. The shapes are the same here; the dispatch is on the JSON token rather than on trial deserialization, which is the same decision made without backtracking.

A string is split on commas, and upstream's does not split. That is a deliberate departure, and it is forced rather than chosen: a comma is one of the four characters Symbols forbids inside a symbol — the live gateway's subscription line separates symbols with it — so Symbols.From("AAPL,MSFT") throws. Upstream's String branch builds a one-element list holding the whole comma-joined value, a "symbol" that cannot be sent back and does not compare equal to the set it came from; the same input here has to either split or fail. Splitting also makes the round trip true, which is the property that matters: this library sends symbols comma-joined (ToApiString()), so comma-joined is exactly the spelling a job echoes back.

AllWireValue is recognised in both positions. #39's probe found the API sends it as a bare string — "symbols":"ALL_SYMBOLS" — which is the case upstream handles. A one-element array holding it is treated the same way here, where upstream would produce an ordinary symbol set naming a symbol called ALL_SYMBOLS. Nothing is lost by being right in a case that may never arrive: the sentinel is not a symbol any exchange lists.

An empty array throws rather than yielding an empty set. There is no such thing as a Symbols naming nothing — From(IEnumerable<string>) refuses it, and a defaulted value throws when rendered — so the alternative to an exception here is a value that fails later, somewhere with less context.

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads and converts the JSON to type Symbols.

public override Symbols Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters

reader Utf8JsonReader

The reader.

typeToConvert Type

The type to convert.

options JsonSerializerOptions

An object that specifies serialization options to use.

Returns

Symbols

The converted value.

Write(Utf8JsonWriter, Symbols, JsonSerializerOptions)

Writes a specified value as JSON.

public override void Write(Utf8JsonWriter writer, Symbols value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The writer to write to.

value Symbols

The value to convert to JSON.

options JsonSerializerOptions

An object that specifies serialization options to use.