title: How to deserialize a blank JSON string value to null for java.lang.String?
body: <p>I am trying a simple JSON to de-serialize in to java object. I am however, getting empty <em>String</em> values for <code>java.lang.String</code> property values. In rest of the properties, blank values are converting to <em>null</em> values(which is what I want).</p>
  
  <p>My JSON and related Java class are listed below.</p>
  
  <p>JSON string:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
    "eventId" : 1,
    "title" : "sample event",
    "location" : "" 
  }
  </code></pre>
  
  <p><em>EventBean</em> class POJO:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class EventBean {
  
      public Long eventId;
      public String title;
      public String location;
  
  }
  </code></pre>
  
  <p>My main class code:</p>
  
  <pre class="lang-java prettyprint-override"><code>ObjectMapper mapper = new ObjectMapper();
  mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
  mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
  
  try {
      File file = new   File(JsonTest.class.getClassLoader().getResource("event.txt").getFile());
  
      JsonNode root = mapper.readTree(file);
      // find out the applicationId
  
      EventBean e = mapper.treeToValue(root, EventBean.class);
      System.out.println("It is " + e.location);
  }
  </code></pre>
  
  <p>I was expecting print "It is null". Instead, I am getting "It is ". Obviously, <em>Jackson</em> is not treating blank String values as NULL while converting to my <em>String</em> object type. </p>
  
  <p>I read somewhere that it is expected. However, this is something I want to avoid for <em>java.lang.String</em> too. Is there a simple way? </p>