I am using Xamarin forms and fetching a list of JSON objects, which are of multiple Types
. E.g.
class BaseClass
{
public int Id;
}
class ClassA: BaseClass
{
public string Name;
}
class ClassB: BaseClass
{
public DateTime DateOfBirth;
}
and so on..
When I fetch such objects (ClassA
, ClassB
, ...), I use the following line to deserialize them into the BaseClass
var response = await RestClient.PostTaskAsync<List<BaseClass>>(request);
And latter try to cast them into ClassA
or ClassB
, only to get null
for all the BaseClass
objects.
I simply expect a List<BaseClass>
containing ClassA
, ClassB
... objects.
What am I missing here? Is there a setting/configuration for the Serializer , where I could pass the specific classes to get the specifically serialized?