Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4066

Jersey - Modify Jackson output by request-parameter in resource method

$
0
0

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?


Viewing all articles
Browse latest Browse all 4066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>