Jax-rs json pretty output

jackson, java, jax-rs, pretty-print

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();
}

Problem

in Java when i use the ``` @Produces("application/json") ``` annotation the output is not formated into human readable form. How do i achive that?

Original source