users@jersey.java.net

Re: [Jersey] How do I marshal nested lists as JSON? I get an array of nulls or an array of one-element dictionaries containing an array.

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 21 Jul 2009 12:30:37 -0700

On Tue, Jul 21, 2009 at 12:04 AM, Martin Probst<mail_at_martin-probst.com> wrote:
>> Just curious here -- what is/was missing from Jackson data binding? I
>> assume you checked it out.
>
> I looked at Jackson, but maybe not long enough. It operates through
> getters and setters, and it doesn't support objects with real

Yes, although since 1.1 also supports direct field access.

> constructors, does it?

Not until 1.2. Funny you should mention this, though, since I am now
working on support for non-default constructors. :-)
It is my personal number one missing feature, to be able to eliminate
setters for most simple beans, but I only now have had time to work on
it.
So it will be available by end of month (assuming I get 1.2 found as planned).

There may be other things that are missing of course. Biggest such
feature that I am aware of is the inability to do polymorphic
deserialization (and hence, it's not a real object serialization
package).
That is one area where JAXB approach can help, because of XML Schema
and type system can theoretically provide more information to allow
sub-classes to be identified.

>> Personally I think that trying to make XML and JSON serialization
>> parts interact (beyond simple things like possibly supporting same
>> bean annotations) is largely waste of time -- both can be solved
>> rather easily separately, as long as canonical data is viewed to be
>> objects. And thereby representations should always derive from the
>> primary canonical source; not from secondary rendition.
>
> I absolutely agree. If you look at it from a more theoretical stand
> point, JSON is a directed graph where the edges are labelled, XML is
> an ordered directed graph where nodes are labelled. There is no way
> you can cleanly convert one to the other, and there shouldn't have to
> be if you start from objects.

Exactly! Your explanation is more concise and better than mine... if
you don't mind, I may reuse it in explaining the issue to others. :-)

-+ Tatu +-