This is a section of my JSON string file.
{
"Abbrev": "ALEX",
"MeetingDate": "/Date(1679058000000+1100)/",
This is the class creation
public class PFGetForm
{
public string Abbrev { get; set; }
public DateTime MeetingDate { get; set; }
I am trying to add the Meeting Date to a list
line.Add($"{form.MeetingDate.ToString("dd/MM/yy")}");
The error message is:
System.Text.Json.JsonException: 'The JSON value could not be converted to System.DateTime. Path: $.MeetingDate | LineNumber: 0 | BytePositionInLine: 61.'
FormatException: The JSON value is not in a supported DateTime format.
Trying to parse the MeetingDate field from the JSON file and add it to a list so I can then send it all to a csv file.
2
Answers
Set your property as string:
and then convert it to timestamp. Demo:
Fiddle:
https://dotnetfiddle.net/puJYxm
I highly recommed you to use Newtonsoft.Json. Otherwise you will not have any time for programming, since you will be very busy creating custom converters for Text.Json .