title: Enable Jackson Deserialization of Empty Objects to Null
body: <p>I was asked to change our jackson mapping configuration so that each empty object we deserialize (from JSON) is going to be deserialized as null.</p>
  <p>The problem is that I'm struggling to do it, but without any luck. Here is a sample of our <code>ObjectMapper</code> configuration (and example):</p>
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
  mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
  mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, true);
  mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
  JavaTimeModule javaTimeModule = new JavaTimeModule();
  javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ISO_DATE_TIME));
  javaTimeModule.addDeserializer(Instant.class, InstantDeserializer.INSTANT);
  mapper.registerModule(javaTimeModule);
  mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  warmupMapper(mapper);
  
  return mapper;
  </code></pre>
  <p>I thought about something like adding:</p>
  <pre><code>mapper.configure(
      DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
  </code></pre>
  <p>but it just works on strings.</p>
  <p>I'm afraid that using a custom deserializer will not help me, because I'm writing a generic (for all objects) mapper. So I probably need something like a delegator or a post process deserialization method.</p>
  <p>So for json like <code>&quot;&quot;</code> or <code>{}</code> I expect to be converted to <code>null</code> in java (and not to empty string or <code>Object</code> instance).</p>