users@jersey.java.net

[Jersey] Re: Unmarshalling JSON into POJO collections

From: John Brooks <iresprite_at_gmail.com>
Date: Tue, 12 Aug 2014 10:12:33 -0400

Just wanted to bump this- I feel like I'm starting to get my head around
things, but the exception is really confusing me!


On Sun, Aug 10, 2014 at 8:52 PM, John Brooks <iresprite_at_gmail.com> wrote:

> 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
>