Q:

Jackson to deserialize Map variable as empty Map instead of null

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. 
JSON:
{"names":null, "descriptions":null, "nicknames":null...}

Java class:
private User {
    private Map<String,String> names = new HashMap<>();
    private Map<String,String> descriptions = new HashMap<>();
    private Map<String,String> nicknames = new HashMap<>();
}

Right now when the ObjectMapper deserializes the JSON, it overrides the fields, and sets names, descriptions, and nicknames as null. 
Is there a a generic way so I would not have to add code each time I have a new map property? 

A:

Add a setter for your map:
public void setNames(Map<String, String> names) {
    this.names = (names == null) ?  new HashMap<>() : names;
}

This setter will be detected by Jackson and will be used when the property is read from the JSON.  So within your setter, you can check if the value is null, and if it is then you create a new HashMap. 

A:

You can setup you own module and override getNullValue()
see doc
http://jackson.codehaus.org/1.9.9/javadoc/org/codehaus/jackson/map/JsonDeserializer.html
Note
I register the Deserializer for all Map.class, not so exact
test code
    SimpleModule module = new SimpleModule("test",  new Version(1, 0, 0, null));

    module.addDeserializer(Map.class, new JsonDeserializer<Map>() {
        @Override
        public Map deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
            return jp.readValueAs(HashMap.class);
        }

        @Override
        public Map getNullValue() {
            return new HashMap();
        }
    });

    mapper.registerModule(module);

test case
String s = "{\"names\":{\"1\":2}, \"descriptions\":null, \"nicknames\":null}";

result
User{descriptions={}, names={1=2}, nicknames={}}

