'Use the same ObjectMapper/JsonSerializer for writing to file as used by Jersey for Responses

I'm using both JSON and XML Serialization in Jersey

ApplicationConfig.java

register(JacksonFeature.class);

Resource classes

@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})

Now for a different use case (in the same application), I need to serialize an (annotated) model to a local file.

I'd like to use the same serializers that Jersey uses for the responses. How can I get access to those?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source