users@jersey.java.net

[Jersey] Re: Question regarding json and attributes

From: John Yeary <johnyeary_at_gmail.com>
Date: Thu, 5 Jan 2012 18:01:20 -0500

I also posted an example changing the context to BadgerFish here:

http://javaevangelist.blogspot.com/2011/12/jax-rs-tip-of-day-changing-json-jaxb.html

On Thu, Jan 5, 2012 at 3:37 PM, Oded Hassidi <oded.hassidi_at_gmail.com> wrote:

> Thanks for the help guys, I like the BadgerFish solution and I am using it
> in the new API I'm exposing but the old already works with attributes and I
> don't want to chat how client works.
>
> Tatu - can you elaborate on your solution, and give a snippet?
>
>
> On Thu, Jan 5, 2012 at 21:58, Tatu Saloranta <tsaloranta_at_gmail.com> wrote:
>
>> On Thu, Jan 5, 2012 at 11:08 AM, John Yeary <johnyeary_at_gmail.com> wrote:
>>
>>> Have you looked at BadgerFish for encoding your JSON objects? The
>>> JAXBContext can be configured to use BadgerFish which handles XML
>>> attributes and values. I think that BadgerFish uses @ symbols so you may
>>> need to change that. It does however encode both attributes and elements
>>> correctly.
>>>
>>
>>
>> Alternatively, you could simplify things by using POJO mapping -- since
>> JSON has no attribute/element distinction, it's much simpler to just ignore
>> those.
>> This does not affect XML side since it would still use JAXB which
>> differentiates between the cases, but there's really no direct connection
>> between XML and JSON bindings: even when using conventions like Badgerfish,
>> workflows are fully separate.
>>
>> -+ Tatu +-
>>
>>
>>
>


-- 
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