title: How to tell Jackson to ignore empty object during deserialization?
body: <p>At the deserialization process (which as I understand is the process of converting JSON data into a Java Object), how can I tell Jackson that when it reads a object that contains no data, it should be ignored?</p>
  
  <p>I'm using Jackson 2.6.6 and Spring 4.2.6</p>
  
  <p>The JSON data received by my controller is as follows:</p>
  
  <pre><code>{
      "id": 2,
      "description": "A description",
      "containedObject": {}
  }
  </code></pre>
  
  <p>The problem is that the object "containedObject" is interpreted as is and it's being instantiated. Therefore, as soon as my controller reads this JSON data, it produces an instance of the ContainedObject object type but I need this to be null instead.</p>
  
  <p>The easiest and fastest solution would be that in the JSON data received, this value be null like this:</p>
  
  <pre><code> {
          "id": 2,
          "description": "A description",
          "containedObject": null
      }
  </code></pre>
  
  <p>But this isn't possible since I'm not in control of the JSON data that is sent to me.</p>
  
  <p>Is there an annotation (<a href="https://stackoverflow.com/questions/16089651/jackson-serialization-ignore-empty-values-or-null">like this explained here</a>) that works for the deserialization process and could be helpfull in my situation?</p>
  
  <p>I leave a representation of my classes for more information:</p>
  
  <p>My entity class is as follows:</p>
  
  <pre><code>public class Entity {
      private long id;
      private String description;
      private ContainedObject containedObject;
  
  //Contructor, getters and setters omitted
  
  }
  </code></pre>
  
  <p>And my contained object class as follows:</p>
  
  <pre><code>public class ContainedObject {
      private long contObjId;
      private String aString;
  
  //Contructor, getters and setters omitted
  
  }
  </code></pre>