title: How can I pass complex objects as arguments to a RESTful service?
body: <p>I have successfully set up a quick test of creating a "REST-like" service that returns an object serialized to JSON, and that was quite easy and quick (based on <a href="http://www.insaneprogramming.be/?p=140" rel="noreferrer">this article</a>). </p>
  
  <p>But while returning JSON-ified objects was easy as peach, I have yet to see any examples dealing with input parameters that are not primitives. How can I pass in a complex object as an argument? I am using Apache CXF, but examples using other frameworks like Jackson are welcome too :)</p>
  
  <p>Client side would probably be something like building a javascript object, pass it into JSON.stringify(complexObj), and pass that string as one of the parameters.</p>
  
  <p>The service would probably look something like this</p>
  
  <pre><code>@Service("myService")
  class RestService {
      @GET
      @Produces("application/json")
      @Path("/fooBar")
      public Result fooBar(@QueryParam("foo") double foo, @QueryParam("bar") double bar,
          @QueryParam("object") MyComplex object) throws WebServiceException {
      ...
      }
  }
  </code></pre>
  
  <p>Sending serialized objects as parameters would probably quickly touch the 2KB URL-limit imposed by Internet Explorer. Would you recommend using POST in these cases, and would I need to change much in the function definitions? </p>