Similar to this stackoverflow thread Jackson with JSON: Unrecognized field, not marked as ignorable
I am getting com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field error.
I don't want to have to save this value in a field on the class. I want it to be computed when it is being serialized. And possibly ignored when it is being deserialized (because then I can just recompute it)
I think this may have to do with the fact that these methods are never called. Because other computed methods which being called are being serialized just fine.
If the method returns a value computed from other properties, make sure it is ignored by Jackson by adding
@ com.fasterxml.jackson.annotation.JsonIgnoreto the method.Alternatively - if you want to serialize the value and ignore it/not fail on deserialization then there are two options I know of:
@JsonIgnoreProperties(ignoreUnknown=true)to the classmapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)on theObjectMapperyou are using for deserialization.