users@jersey.java.net

[Jersey] Re: Question regarding json and attributes

From: John Yeary <johnyeary_at_gmail.com>
Date: Thu, 5 Jan 2012 08:30:47 -0500

JSON is a name=value pair mapping, so order is not important for that. Your
application as noted should be fine.

If you need to have order, you may consider wrapping the objects in a
GenericEntity<List<?>> to maintain some ordering. In general, the arrays
created in JSON are ordered from the Java side of the application. So using
arrays will maintain order from the server side. I can not vouch for what
your client side code will do.

John

On Thu, Jan 5, 2012 at 5:04 AM, Oded Hassidi <oded.hassidi_at_gmail.com> wrote:

> Hi all,
>
> I have Jersey and JAXB used for translating json and xml to objects.
> My objects define attributes and in json they go out with @ sign. In json
> as far as I know there is no importance to the order of the name, value
> pairs.
>
> The question is: if we define attribute do they break the above assumption?
> is this: {"event":{"state":"ended","@type":"state"}}
> different from this: {"event":{"@type":"state", "state":"ended"}}
> when jersey build the java object?
>
> Thanks
>



-- 
John Yeary
--
http://javaevangelist.blogspot.com
http://www.johnyeary.com
*_at_jyeary*
"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
-- Theodore Roosevelt