title: Parsing json into java objects in spring-mvc
body: <p>I'm familiar with how to return json from my <code>@Controller</code> methods using the <code>@ResponseBody</code> annotation.</p>
  
  <p>Now I'm trying to read some json arguments into my controller, but haven't had luck so far.
  Here's my controller's signature:</p>
  
  <pre><code>@RequestMapping(value = "/ajax/search/sync")
  public ModelAndView sync(@RequestParam("json") @RequestBody SearchRequest json) {
  </code></pre>
  
  <p>But when I try to invoke this method, spring complains that:
  <code>Failed to convert value of type 'java.lang.String' to required type 'com.foo.SearchRequest'</code></p>
  
  <p>Removing the <code>@RequestBody</code> annotation doesn't seem to make a difference.</p>
  
  <p>Manually parsing the json works, so Jackson must be in the classpath:</p>
  
  <pre><code>// This works
  @RequestMapping(value = "/ajax/search/sync")
  public ModelAndView sync(@RequestParam("json") String json) {
      SearchRequest request;
      try {
          request = objectMapper.readValue(json, SearchRequest.class);
      } catch (IOException e) {
          throw new IllegalArgumentException("Couldn't parse json into a search request", e);
      }
  </code></pre>
  
  <p>Any ideas? Am I trying to do something that's not supported?</p>