title: Prevent Gson from returning null when deserializing empty strings
body: <p>I am using Gson to serialize and deserialize JSON. In my tests, I found that when I pass my <code>Gson</code> object an empty string, it returns <code>null</code> rather than throwing a <code>JsonParseException</code>. </p>
  
  <p>How can I configure Gson so that it throws an error for empty strings? </p>
  
  <hr>
  
  <p>Here is my deserializer: </p>
  
  <pre><code>public final class ProjectDeserializer implements JsonDeserializer&lt;Project&gt; {
  
      @Override
      public Project deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context) throws JsonParseException {
  
          final JsonObject jsonObject = jsonElement.getAsJsonObject();
  
          final Identifier name = context.deserialize(jsonObject.get("name"), Identifier.class);
  
          Optional&lt;String&gt; license;
          if (jsonObject.has("license")) {
              license = Optional.of(jsonObject.get("license").getAsString());
          } else {
              license = Optional.empty();
          }
  
          DependencyGroup dependencies;
          if (jsonObject.has("dependencies")) {
              dependencies = context.deserialize(jsonObject.get("dependencies"), DependencyGroup.class);
          } else {
              dependencies = DependencyGroup.of();
          }
  
          return Project.of(name, license, dependencies);
      }
  }
  </code></pre>
  
  <p>Here is my <code>Gson</code> factory: </p>
  
  <pre><code>public static Gson gson() {
  
      final GsonBuilder gsonBuilder = new GsonBuilder();
  
      // etc...
  
      gsonBuilder.registerTypeAdapter(Project.class, new ProjectSerializer());
      gsonBuilder.registerTypeAdapter(Project.class, new ProjectDeserializer());
  
      // etc...
  
      return gsonBuilder.create();
  }
  </code></pre>