0

我使用 Java 中的继承创建了一个简单的结构,如下所示

public interface DemoSuper {}

public class Child1 implements DemoSuper{ }

public class Child2 implements DemoSuper{ }

然后我有一个类 DemoContainer 它有 DemoParent 的集合

public class DemoContainer{
    ArrayList<DemoSuper> list = new ArrayList<DemoSuper>();
}

现在,当我尝试使用杰克逊将 D 序列化为 xml 时,我得到了

<DemoContainer>
   <DemoSuper></DemoSuper>
   <DemoSuper></DemoSuper>  
</DemoContainer>

但我想有点像

<DemoContainer>
   <Child1></Child1>
   <Child2></Child2>    
</DemoContainer>

谁能帮我解决这个问题?

4

0 回答 0