@JsonIgnoreProperties usage for both known and unknown properties

Set ignoreUnknown to true and define the names of properties to ignore in the value element:

@JsonIgnoreProperties(ignoreUnknown = true, 
                      value = {"hibernateLazyInitializer", "handler", "created"})

How does it work?

Have a look at this quote from the documentation (highlight is mine):

In its simplest form, an annotation looks like the following:

@Entity

The at sign character (@) indicates to the compiler that what follows is an annotation. In the following example, the annotation’s name is Override:

@Override
void mySuperMethod() { ... }

The annotation can include elements, which can be named or unnamed, and there are values for those elements:

@Author(name = "Benjamin Franklin", date = "3/27/2003")
class MyClass() { ... }

or

@SuppressWarnings(value = "unchecked")
void myMethod() { ... }

If there is just one element named value, then the name can be omitted, as in:

@SuppressWarnings("unchecked")
void myMethod() { ... }

Other way to handle unknown properties

To ignore unknown properties, you also could do:

ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)