Table of Contents

Class LocalDateJsonConverter

Namespace
MassiveDotNet.Serialization
Assembly
MassiveDotNet.dll

Reads and writes a calendar date in the YYYY-MM-DD form the Massive API uses.

public sealed class LocalDateJsonConverter : JsonConverter<LocalDate>
Inheritance
LocalDateJsonConverter
Inherited Members

Remarks

Parses straight from the reader's UTF-8 bytes: no intermediate string, and none of the ParseResult allocation NodaTime's pattern API incurs per value. A reference model with four date fields over a thousand-row page would otherwise allocate eight thousand objects that are discarded immediately.

Registered once on the generated REST serialization context, so every LocalDate property on every model uses it without a per-property attribute. A nullable LocalDate? property resolves to this converter through the serializer's own nullable wrapper.

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads and converts the JSON to type LocalDate.

public override LocalDate 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

LocalDate

The converted value.

Write(Utf8JsonWriter, LocalDate, JsonSerializerOptions)

Writes a specified value as JSON.

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

Parameters

writer Utf8JsonWriter

The writer to write to.

value LocalDate

The value to convert to JSON.

options JsonSerializerOptions

An object that specifies serialization options to use.