Class SplitDurationJsonConverter
- Namespace
- DatabentoDotNet.Historical.Json
- Assembly
- DatabentoDotNet.Historical.dll
Reads and writes SplitDuration as its wire string, reading JSON null as
None.
public sealed class SplitDurationJsonConverter : JsonConverter<SplitDuration>
- Inheritance
-
SplitDurationJsonConverter
- Inherited Members
Remarks
The null case is the whole reason this converter exists, and it is the API's
behaviour rather than a convenience. Upstream found it first and says so in its own hand-written
deserializer: "The API returns null instead of "none" for no time-based splitting"
(batch.rs:672-681). #39 confirmed it against batch.get_job_details, where a job
submitted without a split carries "split_duration":null.
HandleNull is overridden to true, which is
what makes the case reachable at all. Left at its default, the serializer never calls
Read(ref Utf8JsonReader, Type, JsonSerializerOptions) for a null token on a non-nullable value type, and the asymmetry
would be silent: "day" would work, null would not, and the failure would surface
only against a job that happened to have been submitted without a split.
The asymmetry runs one way only. Write(Utf8JsonWriter, SplitDuration, JsonSerializerOptions) emits none rather than null,
because that is what a request carries — see
ToWireString(SplitDuration). Round-tripping this library's own
output therefore takes the string branch, and only the API's output takes the null one.
Properties
HandleNull
true: a null token is a value here, not an absence.
public override bool HandleNull { get; }
Property Value
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type SplitDuration.
public override SplitDuration Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- SplitDuration
The converted value.
Write(Utf8JsonWriter, SplitDuration, JsonSerializerOptions)
Writes a specified value as JSON.
public override void Write(Utf8JsonWriter writer, SplitDuration value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valueSplitDurationThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.