users@jersey.java.net

RE: [Jersey] RE: Set the root when returning a collection

From: Jeremy Whitlock <jwhitlock_at_collab.net>
Date: Fri, 14 Nov 2008 09:10:13 -0800

> Fixed in the main trunk. Jersey in fact was taking the name
> from the appropriate type and was not capitalizing it at all.

Cool.

> Do you mean something like:
>
> [{"person":{"age":"27",...}}, {"person":{"age":...}}]
>
> ?
>
> To me it seems a bit redundant, but i agree people should be able
> to get it (but not by default)

That is what I mean but I also agree that it could be redundant. If I
saw:

{'people': [{'name': ...}, {'name': ...}]}

it should be easy to assume that 'people' corresponds with an array of
people objects. In this scenario, living without more verbosity makes
sense but what about when you have differing types of objects in a List.
I know that might be more of an edge case but without some sort of
element name, it'd be hard to distinguish one time from another.
(Yes...I don't see too many programmers taking a list and populating it
with multiple types of objects so this may be moot but it's worth
mentioning.)
 
> >> 3) In JSON, the root is not plural.
>
> So that you will end up with:
>
> {"people":[{"person":{"age":"27",...}}, {"person":{"age":...}}]}
>
> right?
>
> I agree, people should be able to configure it.

Yeah. For the current approach of not having element names for each
array element, it can be misleading. As it stands now, you don't have
"people". Instead, you have "person" which is corresponds with a list
of "person" objects. It can be confusing.

I appreciate all of the team's hard work. Jersey is an amazing piece of
software. I hope to contribute more than "ideas" at some time in the
near future.

Take care,

Jeremy