title: Why JSON pretty print is not working?
body: <p>I am trying to do the same thing as <a href="https://stackoverflow.com/questions/10532217/jax-rs-json-pretty-output">this question</a>, but I've tried every possibility I found and I could not make it work.</p>
  
  <p>So far, I have this code:</p>
  
  <pre><code>import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  //import javax.ws.rs.core.MediaType;
  
  import org.jboss.resteasy.annotations.providers.jaxb.json.BadgerFish;
  import org.springframework.http.MediaType;
  import org.springframework.stereotype.Controller;
  
  import com.fasterxml.jackson.databind.DeserializationFeature;
  import com.fasterxml.jackson.databind.SerializationFeature;
  import com.fasterxml.jackson.jaxrs.annotation.JacksonFeatures;
  
  @Path(value = "/mock")
  @Controller
  public class MockController {
  
      @BadgerFish
      @GET
      @Path(value = "/get")
      @Produces(MediaType.APPLICATION_JSON_VALUE)
      @JacksonFeatures(serializationEnable = {SerializationFeature.INDENT_OUTPUT})
      public Container getMockedContainer() {
          return newContainer();
      }
  
      @BadgerFish
      @GET
      @Path(value = "/getXML")
      @Produces(value = MediaType.APPLICATION_XML_VALUE)
      public Container getMockedContainerXML() {
          return newContainer();
      }
  
      //MORE CODE HERE
  }
  </code></pre>
  
  <p>I can go to <code>http://localhost:8081/containerMocked/mock/getXML/</code> and get the expected XML output, easy. But when I try <code>localhost/.../get/</code> I get the correct data but not pretty printed.</p>
  
  <p>At least to me, <code>@Produces(MediaType.APPLICATION_JSON)</code> and <code>@JacksonFeatures(serializationEnable =  { SerializationFeature.INDENT_OUTPUT})</code> should be enough.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>DISCLAIMER:</strong> I will not put here what <code>newContainer()</code> does as it involves too many classes. The thing you must understand is that this <code>Main</code></p>
  
  <pre><code>public static void main(String[] args) throws javax.xml.bind.JAXBException {
      Container container = new MockController().newContainer();
      final javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext.newInstance(Container.class);
      javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller();
      marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      marshaller.marshal(container, System.out);
  }
  </code></pre>
  
  <p>Will output:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;container&gt;
      &lt;leaf&gt;
          &lt;id&gt;int32&lt;/id&gt;
          &lt;possibleValues/&gt;
          &lt;type&gt;int32&lt;/type&gt;
          &lt;value&gt;2147483647&lt;/value&gt;
      &lt;/leaf&gt;
      &lt;id&gt;device&lt;/id&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p>and <code>http://localhost:8081/containerMocked/mock/get/</code> will output:</p>
  
  <pre><code>{"container":{"leaf":{"id":{"$":"int32"},"possibleValues":{},"type":{"$":"int32"},"value":{"$":"2147483647"}},"id":{"$":"device"}}}
  </code></pre>
  
  <p><strong>EDIT:</strong> I have just tested <code>@Formatted</code> annotation according to <a href="https://docs.jboss.org/resteasy/docs/3.0.9.Final/userguide/html/json.html#Jackson_JSON_Decorator" rel="nofollow noreferrer">this link</a> and I also got no results.</p>
  
  <p>Why these annotations are not working, but <code>@Produces</code> and <code>@BadgerFish</code> work normally for example?</p>
  
  <p>I would prefer to do it in the most simple way if possible. And for me, the most simple way is make one of the above annotations work as expected.</p>