I'm calling a REST service using Refit and it is deserializing the JSON that is returned using a class definition I provide. One property of the object returned is JSON so I effectively have nested JSON.
I want to deserialize the nested property as a string as I don't know ahead of time what type it is.
Here is the JSON
{
"Id": "f90b443d-300c-4e6d-a488-eb4bbf62889e",
"Type": "e9ccd222-c252-4846-bf16-5936820a3177",
"SharedName": null,
"Cache": 1,
"Data": {
"Description": "Central Coast"
}
},
{
"Id": "f863581b-67e2-49e0-83c9-ab5820715f4f",
"Type": "7d1c81bd-0b94-4b88-998b-14a8fb9dbbfd",
"SharedName": null,
"Cache": 1,
"Data": {
"Name": "Emergency Department (ED) Report"
}
}
Here is my class definition
public class EntityDetails
{
public string Id { get; set; }
public string Type { get; set; }
public string SharedName { get; set; }
public int Cache { get; set; }
public string Data { get; set; }
}
But I get this error:
"Error reading string. Unexpected token: StartObject. Path '[0].Data', line 7, position 14."
Is there a JSON attribute that will tell the deserializer what to do?