users@jersey.java.net

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

From: Vetle Leinonen-Roeim <vetle_at_roeim.net>
Date: Fri, 06 Feb 2015 08:14:10 +0000

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
>