title: Spring Ajax @ResponseBody with null returned values
body: <p>I have about fifty controllers that use @ResponseBody annotation.</p>
  
  <p>Like this:</p>
  
  <pre><code>@RequestMapping(value = "/someUrl.controller", method = RequestMethod.GET)
  public @ResponseBody Object getObject(@RequestParam("id") Long id) {
      Object object = provider.getObject(id);
      return object;
  }
  </code></pre>
  
  <p>Some times getObject method return <code>null</code>. The issues is that on client side I get <strong>empty response</strong> instead of <code>null</code>.</p>
  
  <p>In the initial implementation we have custom <code>JsonView</code> object that works as wrapper without @ResponseBody annotation.</p>
  
  <p>Like this:</p>
  
  <pre><code>@RequestMapping(value = "/someUrl.controller", method = RequestMethod.GET)
  public JsonView&lt;Object&gt; getObject(@RequestParam("id") Long id) {
      Object object = provider.getObject(id);
      return new JsonView(object);
  }
  </code></pre>
  
  <p>So it was working fine.</p>
  
  <p>I have found some solution at <a href="https://stackoverflow.com/questions/18101506/how-do-you-override-the-null-serializer-in-jackson-2-0">How do you override the null serializer in Jackson 2.0?</a> but unfortunatly it works only for fields in the POJOs.</p>
  
  <p>Have you any ideas how in it can be handled?</p>
  
  <p>Thanks in advance! </p>