So I am making an api call and I need to use JsonConvert.DeserializeObject to convert it to a class. The Json structure comes back as the following
{
"fcResponse": {
"responseData": {
"fcRequest": {
"mail": "Emails",
"outlookMail": "Outlook Emails",
(etc.)
}
}
}
}
The problem is that the values that come back inside "fcRequest" varies based on the parameters I am sending.
The class structure is as follows so far
public class GetSubModulesResponse : BaseResponse
{
[JsonProperty("fcResponse")]
public SubModuleResponse Response { get; set; }
}
public class SubModuleResponse
{
[JsonProperty("responseData")]
public SubModuleData Data { get; set; }
}
public class SubModuleData
{
[JsonProperty("fcRequest")]
public SubModuleFIMRequest RequestFIM { get; set; }
[JsonProperty("fcRequest")]
public SubModuleFSRequest RequestFS { get; set; }
}
And this is the basic call structure
GetSubModulesResponse subModuleResponse = new GetSubModulesResponse();
var response = SubmitAPICall();
subModuleResponse = JsonConvert.DeserializeObject<GetSubModulesResponse>(response);
Now I know I obviously can't have the same JsonProperty on both RequestFIM and RequestFS, but what I'm trying to do is somehow find a way to switch which one of those two properties I should use based on a variable.