title: Json mapping with JaxB annotation using Jackson
body: <p>How to serialize this class using Jackson</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.progressivebeef.service.response;
  
  @XmlRootElement(name = "response")
  @XmlSeeAlso({ User.class,             Profile.class,MenuItem.class,Feedlot.class,Document.class,FeedlotDocument.class })
  public final class PBResponse {
  
  private Integer status = FAILURE;
  private String code;
  private String message;
  private Integer totalRecords;
  private List&lt;Model&gt; list = new ArrayList&lt;Model&gt;();
  
  
  public Integer getStatus() {
      return status;
  }
  
  public void setStatus(Integer status) {
      this.status = status;
  }
  
  @XmlElementWrapper(name = "PBBeans")
  @XmlAnyElement
  public List&lt;Model&gt; getList() {
      return list;
  }
  
  public void setList(List&lt;Model&gt; list) {
      this.list = list;
  }
  
  public String getCode() {
      return code;
  }
  
  public void setCode(String code) {
      this.code = code;
  }
  
  public String getMessage() {
      return message;
  }
  
  public void setMessage(String message) {
      this.message = message;
  }
  
  public Integer getTotalRecords() {
      return totalRecords;
  }
  
  public void setTotalRecords(Integer totalRecords) {
      this.totalRecords = totalRecords;
  }
  
  /**
   * @author tiqbal
   * Resets the response.
   */
  public void reset(){
  
      this.status = FAILURE;
      this.list = new ArrayList&lt;Model&gt;();
      this.code = null;
      this.message = null;
      this.totalRecords = null;
  }
  }
  </code></pre>
  
  <p>Jackson is not picking up @XmlElementWrapper @XmlSeeAlso annotations, also Jackson is not mapping @XmlRootElement annotation. I am using Jackson 1.9.0. Jackson is putting elements in the list but not mapping root element of POJO classes.</p>
  
  <p>Here is sample method.
  </p>
  
  <pre><code>package com.progressivebeef.service.impl;
  
  @Service("/ActivityServiceImpl/")
  @Path("/activityservice/")
  public class ActivityServiceImpl implements ActivityService {
  
  @POST
  @Produces(MediaType.APPLICATION_JSON)
  @Override
  public Response inputJson(User user ) {
  
      System.out.println("user ");
  
  
      user.setUser_name("check user name");
  
      Profile profile = new Profile();
  
      profile.setFirst_name("abc");
      profile.setLast_name("khan");
  
      user.setProfile( profile );
  
      PBResponse response = new PBResponse();
      response.getList().add(user);
  
      return Response.ok(response).build();
  }
  }
  </code></pre>
  
  <p>The response it generating is '{"response":{"status":0,"PBBeans":[{"user_name":"check user name","password":"click123","user_role_key":2,"profile":{"first_name":"abc","last_name":"khan","tableName":"pb_profile","pk":"profile_id"},"tableName":"pb_user","pk":"user_id"}]}}'</p>
  
  <p>not picking up the bean's root name inside PBBeans tag.</p>