単純なAPIを使用して、オブジェクトへのxml応答を逆シリアル化する必要があります。オブジェクトを逆シリアル化すると正常に機能しますが、インラインリストを逆シリアル化しようとすると、例外が発生します。org.simpleframework.xml.core.ElementException:要素'Person'は、行のクラスMyPersonsに一致しません。 3.3。
私が間違っていることの手がかり、または複雑なオブジェクトを含むインラインリストを逆シリアル化するための実用的な例をいただければ幸いです。
ありがとう。
添付されているのは、私のオブジェクトの簡略化された例です。
私のxml:
<Persons>
<Person>
<Info>
<ID>1</ID>
<Name>A</Name>
</Info>
<Address>aaa</Address>
<Products>
<Product>
<Name>foo</Name>
<Product>foofoo</Product>
</Product>
<Product>
<Name>bar</Category>
<Product>barbar</Product>
</Product>
</Products>
</Person>
<Person>
<Info>
<ID>2</ID>
<Name>B</Name>
</Info>
<Address>bbb</Address>
<Products>
<Product>
<Name>foo2</Name>
<Product>foofoo2</Product>
</Product>
<Product>
<Name>bar2</Category>
<Product>barbar2</Product>
</Product>
</Products>
</Person>
</Persons>
私のオブジェクト:
@Root(name="Persons")
public class MyPersons {
@ElementList(inline=true)
private List<Person> persons;
}
@Root
public class Person {
@Element
private Info Info;
@Element(required=false)
private String Address;
@ElementList
private List<Product> Products;
public Person(@Element(name="Info") Info Info){
this.Info = Info;
//doing some logic
}
}
public class Product {
@Element
private String Name;
@Element
private String Product;
}
@Root
public class Info {
@Element(required=false)
private String ID;
@Element
private String Name;
}