function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
code developercode developer 

How to get the list of subclasses while deserializing json?

Hi, I have the following scenario

 

public class master{//this is an empty class.

 

}

 

 

public class child1 extends master{

 

public static integer a;

public static integer b;

}

 

public class child2 extends master{

 

public static integer a2;

public static integer b2;

}

 

public class child1Data {

 

public List<master> data;

 

}

 

 

now suppose I get a list of child1 classes in json, I need to parse it.

 

so to parse

 

 

child1Data  Data = (child1Data )JSON.deserialize(response.getBody(), child1Data .class);

 

 

but after deserialization I am getting List<master>  as empty.

 

this is because master class is empty,but need the list of child1 classes in that list to be parsed

 

Please help me out.