Search code examples
javajax-rsjacksonpretty-print

Jax-rs json pretty output


in Java when i use the

@Produces("application/json")

annotation the output is not formated into human readable form. How do i achive that?


Solution

  • Just for the record, if you want to enable the pretty output only for some resources you can use the @JacksonFeatures annotation on a resource method.

    Here is example:

    @Produces(MediaType.APPLICATION_JSON)
    @JacksonFeatures(serializationEnable =  { SerializationFeature.INDENT_OUTPUT })
    public Bean resource() {
        return new Bean();
    }