Let's say I have a virtual class and two classes that extend it and I am getting a JSON response that could be either one of those classes. Is there a way to deserialize the JSON into the appropriate class without examining it manually?
Here are my classes:
public with sharing virtual class BaseClass
{
public Integer id;
}
public with sharing class foo extends BaseClass
{
public String foo;
}
public with sharing class bar extends BaseClass
{
public Integer bar;
}
I want to be able to do something like
Json.deserialize(jsonstring,Class.BaseClass.Descendants)