0

I have a simple JSON file and a corresponding Java class. I want that the deserialization process fails if the JSON file misses one of the properties from the Java class or a property is null. I tried several things e.g. @JsonIncludeProperties or Jacksons deserialization features FAIL_ON_MISSING_CREATOR_PROPERTIES, FAIL_ON_NULL_CREATOR_PROPERTIES. No luck. Also I could not find any help form the Jackson documentation. I almost think that isn't possible at all.

JSON file:

{ 
  "propA": "foo",
  "propB": "bar"
}

Java class:

public class Props {
  public String propA;    
  public String propB;
}   

I skiped the boilerplait code like getter or setter to make the example as small as possible.

Easterwood
  • 102
  • 1
  • 10

0 Answers0