title: Jackson to deserialize Map variable as empty Map instead of null
body: <p>I'm using Jackson to deserialize a JSON that could contain null values for Map variables. What I want is if the value is null, I want the map to be an empty HashMap instead of null.</p>
  
  <p>JSON:</p>
  
  <pre><code>{"names":null, "descriptions":null, "nicknames":null...}
  </code></pre>
  
  <p>Java class:</p>
  
  <pre><code>private User {
      private Map&lt;String,String&gt; names = new HashMap&lt;&gt;();
      private Map&lt;String,String&gt; descriptions = new HashMap&lt;&gt;();
      private Map&lt;String,String&gt; nicknames = new HashMap&lt;&gt;();
  }
  </code></pre>
  
  <p>Right now when the <code>ObjectMapper</code> deserializes the JSON, it overrides the fields, and sets <code>names</code>, <code>descriptions</code>, and <code>nicknames</code> as null.</p>
  
  <p>Is there a a generic way so I would not have to add code each time I have a new map property?</p>