title: REST + json + JAXB + namespaces
body: <p>I have been trying to wrap my head around POSTing json to a REST service and JAXB namespaces.  I am using Resteasy to mark up the server side method.  I have the following service:</p>
  
  <pre><code>@POST
  @Mapped(namespaceMap={@XmlNsMap(namespace="http://acme.com", jsonName=""))
  @Path("/search")
  @Consumes("application/json")
  public List&lt;I&gt; search(SearchCriteria crit);
  </code></pre>
  
  <p>I have the following objects:</p>
  
  <pre><code>@XmlRootElement(namespace="http://acme.com")
  public class DateCriteria {
      @XmlElement
      private Date start;
      @XmlElement
      private Date end;
  }
  
  
  @XmlRootElement(namespace="http://acme.com")
  public class MultCriteria {
      @XmlElementRefs({@XmlElementRef(type=DateCriteria.class)})
      private List&lt;DateCriteria&gt; dateCriterias;
  }
  </code></pre>
  
  <p>I can send the following JSON in a post and it works:</p>
  
  <pre><code>{ "acme.MultCriteria": { "acme.DateCriteria": { startDate: "2009/01/01", endDate: "2009/01/01" } } }
  </code></pre>
  
  <p>On the service, I get a MultCriteria object with a single element list of DateCriteria's.  Strangely, I have to pass the namespace in the JSON object even though I marked the service with a map to the empty namespace.</p>
  
  <p>If I try to send an array as follows:</p>
  
  <pre><code>{ "acme.MultCriteria": { "acme.DateCriteria": [ { startDate: "2009/01/01", endDate: "2009/01/01" }, { startDate: "2009/01/01", endDate: "2009/01/01" } ] } }
  </code></pre>
  
  <p>I get a MultCriteria object with an empty List of DateCriteria.  If I modify the DateCriteria object so that it has an empty namespace, then the above syntax works fine.</p>
  
  <p>Does anyone see what I am doing wrong here?  How should the namespaces be setup and how do I properly pass them in to the service?</p>