Structr
Search…
DateOnly
DateOnlyJsonConverter provides functionality for converting a DateOnly to or from JSON.

Usage

For example some serializable class:
class Person
{
public DateOnly DateOfBirth { get; set; }
}
Deserialize:
var options = new JsonSerializerOptions();
options.Converters.Add(new DateOnlyJsonConverter());
string json = "{ \"DateOfBirth\": \"1903-05-01\" }";
Person person = JsonSerializer.Deserialize<Person>(json, options);
DateOnly dateOfBirth = person.DateOfBirth; // ---> 1903-05-01
Copy link
Edit on GitHub