I am using Newtonsoft to deserialize JSON from a REST call to a C# object. The object is a list of Person. The Person has a lot of properties but right now I am only storing some of them. I want to have a string property on the Person that contains the JSON that makes up the whole person. Is there a way to do this? I am writing it back to a SQL database for now and I don't need the values but want to have it for future use if needed.
Object class
public class Worker
{
public string associateOID { get; set; }
public WorkerID workerID { get; set; }
public Person person { get; set; }
public WorkerDates workerDates { get; set; }
public WorkerStatus workerStatus { get; set; }
public List<WorkAssignment> workAssignments { get; set; }
public CustomFieldGroup customFieldGroup { get; set; }
public BusinessCommunication businessCommunication { get; set; }
public string JSON { get; set; }
}
public class Meta
{
public int totalNumber { get; set; }
}
public class WorkerResult
{
public List<Worker> workers { get; set; }
public Meta meta { get; set; }
}
My existing call to deserialize:
WorkerResult result = JsonConvert.DeserializeObject<WorkerResult>(json);