Serializing .NET 6s new DateOnly to JSON
The DateOnly type that was introduced in .NET 6 is convenient for exchanging strongly typed date information
in APIs. Unfortunately, the ever popular JSON format has no standard for date fields. This leads to
UnsupportedTypeConverter errors when trying to serialize these fields using System.Text.Json. This article explains
how to create a custom JsonConverter to define the serialization format for DateOnly fields and how to show the
correct format in generated Swagger documentation.
read more