I'm using Moxy in my Jersey (2.7) project basically just to marshall my objects to JSON when the service issues a response. It works fine, but now I am also using ContainerResponseFilter to make some changes on every response issued and I am not sure how to unmarshall the content of the request body into an object, which is something I need.
Specifically:
- i've just registered Moxy in a
ResourceConfig
instance:register(MOXyJsonProvider.class)
- a class is using JAXB annotations, so when I set an instance of the class in Response.entity() it gets transformed into JSON properly
the request body (also JSON) also gets unmarshalled into an object when I set it as a method paramether, for instance:
@Consumes(MediaType.APPLICATION_JSON) public Response getSomething( MyClass instance ) {
However inside a ContainerResponseFilter I can access the request body like so,
InputStream body = requestContext.getEntityStream()
but I'm not sure if it's possible to have this also automatically converted into an object. The information I need is relatively simple, so I guess I could parse JSON in another way, but I'm curious.
I've tried searching, but I didn't find it.