Hmm... I didn't try that. I tried @XmlElements(@XmlElement(type = Person.class)) and that seemed to work. I had previously thought that annotation was only for collections, but it worked for me here.
I have seen in other JSON where "type" appears as a field, but that wasn't working in this case for some reason. Also, it can be kind of confusing with namespaces, since there is no way in JSON notation to specify a namespace prefix, but it nonetheless shows up. For example, I've seen: "type":"ns2:scaleObservation". What the heck is ns2? It's not bad if I'm both the author and the consumer of the service, but for a third party, it can be pretty confusing.
Anyway, that's an aside. My current problem is solved and thanks everyone for the help.
On Dec 15, 2010, at 5:07 AM, Moises Lejter wrote:
> On the JAXB side, you could annotate your root class with @XmlSeeAlso(), and list there all your child types ...
>
> Moises
>
> Sent from my iPhone
>
> On Dec 15, 2010, at 5:54 AM, Paul Sandoz <Paul.Sandoz_at_oracle.com> wrote:
>
>> How are you generating the JSON?
>>
>> In the XML equivalent there should be an "xsi:type" attribute that declares the type and gives JAXB enough clues on what to do. That information should also be present in the JSON.
>>