title: Jackson: Array list wrapper in JAX-RS application
body: <p>The following REST API list service returns a list of Messages. Using Jackson XML serializer, the response list generated with <code>&lt;ArrayList&gt;</code> warapper element. But, I require a JAXB style output with plural wrapper element <code>&lt;Messages&gt;</code>. Is it possible to achieve this without the need to create a wrapper <code>Messages</code> class.</p>
  
  <pre><code>@GET
  @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
  public Response getMessages() throws Exception {
      List&lt;Messages&gt; messages = new ArrayList&lt;Messages&gt;();
      messages.add(new Message("abc"));
      messages.add(new Message("xyz"));
      messages.add(new Message("pqr"));
  
      return Response.status(200).entity(messages).build();
  }
  
  public class Message {
      @JacksonXmlProperty
      private String msg;
  
      public String getMsg() {
          return msg;
      }
      public void setName(String msg) {
          this.msg = msg;
      }
  
      public Message(String msg) {
          this.msg = msg;
      }
  }
  </code></pre>
  
  <p>Observed output:</p>
  
  <pre><code>&lt;ArrayList&gt;
      &lt;item&gt;
          &lt;Msg&gt;abc&lt;/Msg&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;Msg&gt;xyz&lt;/Msg&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;Msg&gt;pqr&lt;/Msg&gt;
      &lt;/item&gt;
  &lt;/ArrayList&gt;
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>&lt;Messages&gt;
      &lt;Message&gt;
          &lt;Msg&gt;abc&lt;/Msg&gt;
      &lt;/Message&gt;
      &lt;Message&gt;
          &lt;Msg&gt;xyz&lt;/Msg&gt;
      &lt;/Message&gt;
      &lt;Message&gt;
          &lt;Msg&gt;pqr&lt;/Msg&gt;
      &lt;/Message&gt;
  &lt;/Messages&gt;
  </code></pre>