Class DateTimeRangeJsonConverter
- Namespace
- DatabentoDotNet.Historical.Json
- Assembly
- DatabentoDotNet.Historical.dll
Reads a DateTimeRange from the {"start":…,"end":…} object the
get_dataset_range response nests under each schema.
public sealed class DateTimeRangeJsonConverter : JsonConverter<DateTimeRange>
- Inheritance
-
DateTimeRangeJsonConverter
- Inherited Members
Remarks
DateTimeRange arrived in #33 as a request-only type — it renders
StartUnixNanoseconds onto a form and was never read back. This is
the first response that carries one (metadata.rs:317), and the wire spelling on the way
in is an ISO timestamp rather than the nanoseconds it goes out as.
An inverted or empty range is rejected by Between(Instant, Instant) itself, and that ArgumentException is translated to JsonException here rather than escaping: a malformed body is a JSON problem from the caller's side, and letting an ArgumentException out of a deserializer would name a parameter the caller never passed.
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type DateTimeRange.
public override DateTimeRange Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- DateTimeRange
The converted value.
Write(Utf8JsonWriter, DateTimeRange, JsonSerializerOptions)
Writes a specified value as JSON.
public override void Write(Utf8JsonWriter writer, DateTimeRange value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valueDateTimeRangeThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.