title: Is there a way of GSON to be "not lenient" at all?
body: <p>It seems that GSON silently ignores when a JSON string contains field names that don't match the target POJO class. One solution outlined <a href="https://stackoverflow.com/questions/14242236/let-gson-throw-exceptions-on-wrong-types">here</a> suggests to use annotations to mark "required" fields to have GSON fail when de-serializing strings that don't contain fields.</p>
  
  <p>But we defined that our POJOs must be "exact" matches (when we allow for incoming objects to be null, they must be declared as Optional field in the POJO - and we have a special type adapter that turns nulls into Optional.empty() instances). Therefore <em>all</em> fields in the POJO are mandatory. And null isn't a valid value.</p>
  
  <p>Following the guidance in that question I linked to, it seems that the <em>only</em> way of having gson fail while parsing: to do a full "deep reflection" scan of the object created by de-serialization process and check if any of the Optional fields are null. </p>
  
  <p>Or maybe - I am missing something and there is an easier way to have gson <em>tell</em> me when our JSON strings contain bad field names?</p>
  
  <p>( background: we just ran into a problem because of wrong field name deep down in a nested structure - leading to null objects where we didn't expect them )</p>