title: How to POST a JSON request containing an array of objects?
body: <p>On the server side, I have a method which looks like this:</p>
  
  <pre><code>@POST
  @Path("/foods/{year}/{month}/{day}")
  @Consumes("multipart/mixed")
  @Produces("application/json; charset=UTF-8")
  @Transactional
  public boolean setFoodsForTheDay(@PathParam("year") int year, @PathParam("month") int month,
    @PathParam("day") int day, @Multipart(value = "foodList", type = MediaType.APPLICATION_JSON) Food[] foodList) {
  
    if (log.isDebugEnabled()) {
      log.debug("list size={}", foodList.size());
    }
    doStuff(foodList);
  
  }
  </code></pre>
  
  <p>If I send in the following POST request to /foods/2013/06/26 it will actually work and the array will get parsed correctly:</p>
  
  <pre><code>Host: localhost:7777
  Accept: application/json
  Content-Type: multipart/mixed; boundary=---------------------------25819220131967
  Content-Length: 226
  
  -----------------------------25819220131967\r\n
  Content-Disposition: form-data; name="foodList"\r\n
  Content-Type: application/json\r\n
  \r\n
  [   {"id":null,"name":"Banana","recipe":null}   ]\r\n
  -----------------------------25819220131967--\r\n
  </code></pre>
  
  <p>As you can see, it's important to send in a <strong>multipart/mixed</strong> (or perhaps multipart/form-data would work too) because then I can set the Content-Type of the part, and it will get parsed correctly.</p>
  
  <p>This all works. Now the problem is, I need to send this request in with jQuery (or any other Ajax tool) and looks like it's not possible to send multipart/mixed? Or there's some trick with an iframe but it will still not be possible to set the <strong>Content-type</strong> of the part.</p>
  
  <p>Does anyone know of a solution for this problem? How can I send in an array of objects to the server in JSON serialization?</p>