© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
20 replies
Core

✅ NodaTime JSON Serialization

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

Assuming I accept an
Instant
Instant
in the DTO and a request comes in, but the format is not
ISO-8601
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
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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ JSON serialization fails
C#CC# / help
3y ago
❔ ✅ JSON Serialization not working?
C#CC# / help
3y ago
Newtonsoft.Json Serialization Exception
C#CC# / help
3y ago
❔ JSON Serialization Weird Model
C#CC# / help
4y ago