I have an Object "information" like this:
public class information
{
[JsonProperty]
public DateOnly date;
[JsonProperty]
public string summary;
[JsonProperty]
public TimeOnly endTime;
[JsonProperty]
public TimeOnly startTime;
}
now I want to serialize this object, but however I cannot serialze DateOnly and TimeOnly. This is how I serialize
List<information>? liste = new List<information>();
private static void WriteFile(DateOnly date, string summary, TimeOnly startTime, TimeOnly endTime)
{
information jsonnAppointment = new information()
{
date = date,
summary = summary,
startTime= startTime,
endTime = endTime
};
List<information> liste = GetJsonInfo();
liste.Add(jsonnAppointment);
using (FileStream fs = System.IO.File.Open(_appointmentPath + "appointment.json", FileMode.Open))
{
byte[] info = new UTF8Encoding(true).GetBytes(JsonConvert.SerializeObject(liste));
fs.Write(info, 0, info.Length);
}
I tried to install other packages from Newtonsoft.