users@jersey.java.net

[Jersey] Unmarshalling JSON into POJO collections

From: John Brooks <iresprite_at_gmail.com>
Date: Sun, 10 Aug 2014 17:52:02 -0700

Hey all! I have a followup question regarding turning JSON into a java
object. I'm trying to take JSON objects and put them into a collection. I
tried the following approaches:

List<Character> characters = response.readEntity(new
GenericType<List<Character>>(){});

List<Character> characters =
client.target(uri).request(MediaType.APPLICATION_JSON).get(new
GenericType<List<Character>>(){});

Using those approaches got me the following:

Exception in thread "main" java.lang.ClassCastException: Character cannot
be cast to java.util.List

I'm confused; I thought I was creating a generic List that contained
Character objects in my declaration. The documentation doesn't appear to
contradict this; any thoughts?

Thanks!
John