Hi Bill
I tried both methods and both work.
I also tried to mix them TypeLiteral at one end and ListOfPerson at the other;
but that's not good :)
Thanks
anton
On 07/02/2011 22:15, Bill van Melle wrote:
Yeah, we had a long exchange (and some bug fixes) about this a couple months ago. Java's type
erasure means you can't get a Class object specialized to your type, so there's a crufty
workaround using a pivot utility class, which I think goes like this:
Type type = (new TypeLiteral<ArrayList<Person>>() {}).getType();
after which you can do new JSONSerializer(type).
Alternatively, you can create a trivial class:
class ListOfPerson extends <ArrayList<Person> {
}
and then do new JSONSerializer(ListOfPerson).
On Mon, Feb 7, 2011 at 11:30 AM, anton dos santos <[email protected]
<mailto:[email protected]>> wrote:
Hi
i am using QueryServlet and WebQuery to exchange data between the server
and the Pivot client,
which works fine for simple beans.
But I don't know how to instanciate the JSONSerializer when I want to send
a collection of
beans : let's say org.apache.pivot.collections.ArrayList<Person>.
When I do : new JSONSerializer(ArrayList.class) , the client receives an
ArrayList of
HashMap; but I'd like to get an ArrayList of Person.
How can this be done?
Regards
Anton