users@jersey.java.net

Abstract JSON serialization problem in 1.1.2-ea

From: Fetig, Matthew <matthew.fetig_at_lmco.com>
Date: Wed, 09 Sep 2009 16:20:10 -0600

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>