bluelinelabs / LoganSquare

Screaming fast JSON parsing and serialization library for Android.
Apache License 2.0
3.21k stars 306 forks source link

how to serialize/parse arraylist with different object type #145

Closed hhuimie closed 8 years ago

hhuimie commented 8 years ago

code below: class A:

public class A {
    public int i;
}

class B:

public class B {
    public String name;
}

and the list:

List list = new ArrayList<>();
list.add(new A());
...
list.add(new B());
...

I wanna know how to serialize the list to string and parse the string to list. I'm so sorry if I'm asking a stupid question. Thanks!

EricKuck commented 8 years ago

This isn't supported, as the library would have no idea what kind of class it should parse to in this case.

hhuimie commented 8 years ago

editing.