users@jersey.java.net

[Jersey] Re: Creating an EmberJS-friendly REST API

From: Dietz, Randall <randall_at_dietz.id.au>
Date: Fri, 6 Feb 2015 01:03:32 -0800

Cheers Vetle,

While that might work, I don't want to have to wrap all my POJO's to alter
the JSON formats... sounds a bit clunky. It appears that it can be done in
Jersey, but I can't find any working examples.



On Fri, Feb 6, 2015 at 12:14 AM, Vetle Leinonen-Roeim <vetle_at_roeim.net>
wrote:

> What does your POJO look like? Dont' you just need to add a wrapper class,
> something like this:
>
> public class Foo {
> private Widget widget;
>
> // Getters & setters
> }
>
> That would serialize the Foo class, and since it has a property called
> "widget", it should output { "widget": { ... }}
>
> On Fri Feb 06 2015 at 8:38:06 AM Dietz, Randall <randall_at_dietz.id.au>
> wrote:
>
>> Hi all,
>>
>> EmberJS is expecting JSON in the format of:
>>
>> { "widget": {"id":123, "name":"widget123"}}
>>
>> Out of the box, my Genson-enabled POJO format is:
>>
>> {"id":123, "name":"widget123"}
>>
>> This topic doesn't appear to be covered very much on the InterWeb... what
>> few "solutions" I can find are mostly incomplete or confusing.
>>
>> I suspect Genson does not produce this kind of JSON... but can someone
>> recommend a solution that can?
>>
>> Thanks
>>
>