users@jersey.java.net

[Jersey] Re: Unmarshalling JSON into POJO collections

From: John Brooks <iresprite_at_gmail.com>
Date: Wed, 13 Aug 2014 09:15:22 -0400

You know, I just might feel like a complete fool right about now. I'll have
to look into that.


On Wed, Aug 13, 2014 at 4:09 AM, Mikael Ståldal <
mikael.staldal_at_appearnetworks.com> wrote:

> This might not be your problem, but Character might not be the best name
> of a class since it can easily be confused with java.lang.Character which
> is imported by default everywhere.
>
>
>
> On Tue, Aug 12, 2014 at 4:12 PM, John Brooks <iresprite_at_gmail.com> wrote:
>
>> 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
>>>
>>
>>
>
>
> --
> Mikael Ståldal
> Chief Software Architect
> *Appear*
> Phone: +46 8 545 91 572
> Email: mikael.staldal_at_appearnetworks.com
>