I am calling an external API, which is returning me JSON data but with 3 different schema.
I have created 3 model class
public class Test1
{
string Name {get;set;}
int age {get;set;}
}
public class Test2
{
int sal {get;set;}
int age {get;set;}
}
public class Test3
{
string Name {get;set;}
int age {get;set;}
bool Valid {get;set;}
}
My question is how would I do the deserialization to that object class from json without reading the data first as I am dont know what will be the correct schema?
i.e Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json)
Twith the class that you are expecting. You should know which schema you are expecting depending on the request's route, parameters, content, and headers.