I have an issue when trying to map a JSON response I get from an API into an appropriate object that I made. Following is the JSON example
{
"Count": "1",
"Data": {
"EmployeeMstr": {
"ledger": "GL",
"faid": "_tag_"
}
}
}
I need to create and object so that i can deserialize the above Json. I can create an object and desiarilse using JsonConvert.DeserializeObject<ResponseObject>(jsonResponse)
. Where ResponseObject is the class I created like following.
public class ResponseObject
{
public string Count { get; set; }
public string NextUri { get; set; }
public Data Data{ get; set; }
}
public class Data
{
public string EmployeeMstr { get; set; }
}
But the issue with this is, the key name "EmployeeMstr"
in the above Json can be anything depending upon which table it is coming from ( like "HrNewHire" ,"Payroll"
etc). I don't want to create separate object for all seperated tables. So what could be the best approach so that I can use this class to serialize the JSON irrespective of what that table name is?