Hi default tomee 1.7.x json provider relies on jettison. It is configurable as any JAX-RS @provider but has several pitfalls. I would recommand you to switch to either johnzon (tomee 7 default provider) adding johnzon-jaxrs dependency or jackson provider.
End of this page http://tomee.apache.org/ng/developer/json/index.html explains how to configure it. Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> | JavaEE Factory <https://javaeefactory-rmannibucau.rhcloud.com> 2016-08-01 16:55 GMT+02:00 gchauvet <[email protected]>: > Hi everybody, > > I search a conveniant way to format an object list sended by my ejb > restfull > API (work with TomEE+ 1.7.4). I would like to remove the enclosing objet > that contain my list; eg: > > { > "tiers": [ > { > "id": 1006384, > "value": 12 > }, > { > "id": 1006385, > "value": 11 > } > ] > } > > What I would want : > > [ > { > "id": 1006384, > "value": 12 > }, > { > "id": 1006385, > "value": 11 > } > ] > > > My ejb code is like this: > @Path("/") > @GET > public Response list(@QueryParam("offset") @DefaultValue("0") final int > offset, @QueryParam("limit") @DefaultValue("20") final int limit) { > final TypedQuery<Tiers> query = em.createNamedQuery(Tiers.FIND_ALL, > Tiers.class); > query.setFirstResult(offset); > query.setMaxResults(limit); > return Response.ok(new > GenericEntity<Collection<Tiers>>(query.getResultList()){}).build(); > } > > > Best regards, > > > > -- > View this message in context: > http://tomee-openejb.979440.n4.nabble.com/ejb-restful-Customize-JSON-XML-generation-tp4679564.html > Sent from the TomEE Users mailing list archive at Nabble.com. >
