C#C
C#16mo ago
Core

✅ NodaTime JSON Serialization

Hello,
.NET will parse any date format to
DateTime
or
DateTimeOffset
, but what happens if I give NodaTime control over the serialization?

Assuming I accept an
Instant
in the DTO and a request comes in, but the format is not
ISO-8601
, will it be able to convert any type of date like .NET does, or will it only work with strict types?

From the docs:
Between releases 4.0 and 4.5.11, Json.NET introduced automatic date parsing: by default, if the parser detects a value which looks like a date, it will automatically convert it to a DateTime or (optionally) to a DateTimeOffset. In order to give Noda Time control over the serialization, this must be disabled in JsonSerializerSettings or JsonSerializer
Was this page helpful?