Class MappingIntervalJsonConverter
- Namespace
- DatabentoDotNet.Historical.Json
- Assembly
- DatabentoDotNet.Historical.dll
Reads a MappingInterval from the three-key object the symbology API spells it
with: d0, d1 and s.
public sealed class MappingIntervalJsonConverter : JsonConverter<MappingInterval>
- Inheritance
-
MappingIntervalJsonConverter
- Inherited Members
Remarks
A converter here rather than attributes on MappingInterval itself.
Upstream can put #[serde(rename = "d0")] straight on the field
(dbn/src/metadata.rs:452-467) because serde is one crate-level feature flag away. The
equivalent — [JsonPropertyName] — would make DatabentoDotNet.Dbn reference
System.Text.Json, which today it does not, anywhere: that assembly is a binary
codec and these three keys are the JSON spelling of one HTTP endpoint's response. The
dependency belongs on the side that already has it.
The keys are unreachable by naming policy, which is why this is a converter and not a
rename. MetadataJson and SymbologyJson both apply
JsonKnownNamingPolicy.SnakeCaseLower, and no policy turns StartDate into
d0. Without this, every interval would deserialize with all three members at their
defaults — two 0001-01-01 dates and a null symbol — and no exception anywhere, because
unmatched JSON properties are skipped by default. That is the failure this library exists to
turn back into something visible, so the reader below rejects an interval missing any of the
three rather than filling in a default.
Fields
EndDateKey
The wire key for the interval's exclusive end date.
public const string EndDateKey = "d1"
Field Value
StartDateKey
The wire key for the interval's inclusive start date.
public const string StartDateKey = "d0"
Field Value
SymbolKey
The wire key for the resolved symbol.
public const string SymbolKey = "s"
Field Value
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type MappingInterval.
public override MappingInterval Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- MappingInterval
The converted value.
Write(Utf8JsonWriter, MappingInterval, JsonSerializerOptions)
Writes a specified value as JSON.
public override void Write(Utf8JsonWriter writer, MappingInterval value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valueMappingIntervalThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.