jaxb - Shared refrences with json -
is possible make use of concept of shared references json output mode? read article http://blog.bdoughan.com/2010/10/jaxb-and-shared-references-xmlid-and.html), changing @produces on jax-rs json forces endless loop. want reduce object it`s id:
public class foo { private long id; private string sometext; private bar bar; }
i want bind instances of so:
{ "id": 1234, "sometext": "lorem", "bar_id": 9876 }
this want avoid:
{ "id": 1234, "sometext": "lorem", "bar": { "id": 9876, "anothertext": "ipsum" } }
note: i'm eclipselink jaxb (moxy) lead , member of jaxb (jsr-222) expert group.
with moxy json-binding provider shared references post referenced (from blog) work json xml. since using jax-rs below example of configuring moxy in environment:
when using @xmlid
/@xmlidref
expected object being reference id exist in document. since isn't use case better off using xmladapter
. xmladapter
have signature similar to:
public class baradapter extends xmladapter<integer, bar> { ... }
in xmladapter
responsible returning id instance of bar
during marshal, , returning instance of bar
based on id
during unmarshal.
Comments
Post a Comment