I'm having an issue with converting a one part of a JSON string to C# List. The original code didn't have the [JsonProperty] and it that's where the issue started. I added the [JsonProperty] to the MdId value, but the issue is still happens.
C# Class
public class PendingPatientDocumentRecord
{
public int PatientDocumentFileMapId;
public short ContextTypeId;
public string PatientVisitId;
public List<string> BillingIds;
public DateTime? DateOfService;
[JsonProperty("MdId")]
public List<string> MdId;
}
Deserialization code
List<PendingPatientDocumentRecord> pendingDocuments = JsonConvert.DeserializeObject<List<PendingPatientDocumentRecord>>(pendingDocumentsJson);
JSON String:
[
{
"PatientDocumentFileMapId":12,
"ContextTypeId":3,
"DateOfService":"08/31/2022",
"MdId":"ala"
}
]
Error:
Error converting value "ala" to type System.Collections.Generic.List`1[System.String]'. Path '[0].MdId'