Comment on page
DateOnly
DateOnlyJsonConverter
provides functionality for converting a DateOnly
to or from JSON.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
Last modified 1yr ago