Java 如何获取对象列表的点类?
我想用SimpleFramework xml序列化一个对象列表。 我成功地使用了普通类,但没有使用对象列表Java 如何获取对象列表的点类?,java,android,simple-framework,Java,Android,Simple Framework,我想用SimpleFramework xml序列化一个对象列表。 我成功地使用了普通类,但没有使用对象列表 List< Shop > shop = new Persister().read(List<Shop>.class, data); 我找不到好的语法来处理对象列表 List< Shop > shop = new Persister().read(List<Shop>.class, data); ListShop=new Persister
List< Shop > shop = new Persister().read(List<Shop>.class, data);
我找不到好的语法来处理对象列表
List< Shop > shop = new Persister().read(List<Shop>.class, data);
ListShop=new Persister().read(List.class,data);
List.class
不起作用
谢谢不可能直接这么做;改用 下面是一个例子: 商店级 列表示例 这只是列表的包装
@Root(name = "example")
public static class ListExample
{
@ElementList(name = "Shops", inline = true)
private List<Shop> shops;
// ...
}
Type collectionType=newtypetoken>({}.getType()代码>谢谢你的回答,我试过了,但不起作用。这是因为类型擦除。谢谢,我已经做过了,但我希望这是用List进行序列化的另一种方法。
String input = ... // Or what source you have
Serializer ser = new Persister();
ListExample readExample = ser.read(ListExample.class, input);