users@jersey.java.net

Re: [Jersey] Abstract JSON serialization problem in 1.1.2-ea

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Thu, 10 Sep 2009 10:41:24 +0200

Matthew,

could you please file this as a bug [1], and attach a simple reproducible test case,
ideally a maven project.

Thanks,

~Jakub

[1]https://jersey.dev.java.net/issues

On Wed, Sep 09, 2009 at 04:20:10PM -0600, Fetig, Matthew wrote:
> We have just upgraded to 1.1.2-ea and are having problems with the JSON output for an abstract object. Here is an example of the problem we are having:
>
> Say you are serializing an object of type ShoppingCart. A shopping cart contains a list of Items, which is an abstract object. When the response is returned it has the implementation of item, but the JSON produced is only serializing the information in the Item object and not any of the attributes of the implementation of Item. I.E.:
>
> class Item{
> public String itemNumber;
> }
>
> class CD extends Item{
> public String title;
> }
>
> What is getting serialized:
> {'items':[{'itemNumber':'156XC'}]}
>
> What should be serialized:
> {'items':[{'itemNumber':'156XC', 'title':'Test CD'}]}
>
> This was working in the previous version we were using, but is no longer working. We are using natural notation. Any insight you could provide as how the renderer scans the classes for notations and how it decides what to render would be appreciated.
>
> Matt Fetig
> Lockheed Martin Integrated Systems & Global Services
> Software Engineer
> 9970 Federal Drive
> Colorado Springs, CO 80921
> Phone: 719.277.5718
> E-mail: matthew.fetig_at_lmco.com<mailto:matthew.fetig_at_lmco.com>
>

-- 
Jakub Podlešák, Software Engineer                                                             
Web Services and Technologies, SUN Microsystems                                               
http://blogs.sun.com/japod