I'm currently using Jersey & Jackson for creating a REST service.
Right now when a resource method produces application/json
and returns a POJO, it properly serializes the object into JSON and returns the response to the client.
What I'm looking to do
I want to setup Jersey so that, when a query-parameter comes in (lets say "indent"
), I can tell Jackson to serialize the JSON in a prettier format - indented.
You can easily tell Jackson to do this by configuring the JSON mapper (objectMapper
) with SerializationConfig.Feature.INDENT_OUTPUT
.Not sure how to get access to the mapper within the resource method (on a per-request basis).
How do I take a query-parameter and use that to modify Jackson's output - on a per-request basis?