Jackson's FAIL_ON_UNKNOWN_PROPERTIES feature gets me every time. I never remember to turn it off for production systems. Why this is on by default amazes me.

Why would you want to stop de-serialization if there's an extra property the entity does not use.

It makes forward compatibility a pain to manage especially with messaging systems where message content grows and you don't want to go over every service to add a property.

Could we please turn this feature off by default?

#Java #Jackson

@john Hi, I’m not sure if you saw @mehmandarov’s article posted just a little while before your question:

https://mastodon.social/@mehmandarov/116792525382514461#

He describes Jackson as “strict” and other JSON libraries as “lenient”. Why is Jackson strict? I don’t know the actual reason but I have a plausible guess: an “extra” but unknown property might change the interpretation of one of the known properties.

#Java #Jackson (1/2)

With the room example, the "floor" member indicates the floor of the building. But does «"floor": 1» indicate the ground floor (US style) or the first floor above ground level (EU style)? A new version might add «"groundFloor": 0» to indicate which convention is used. A strict implementation would give an error if "groundFloor" isn’t expected. This certainly can be inconvenient but it might be better than silently processing the record incorrectly. (2/2)
@john @mehmandarov

@stuartmarks @mehmandarov

Thanks for the link, I hadn't seen it! It describes exactly the same issue.

I want to add though that this isn't strictly about REST, this also affects message brokers.

The point of recognizing added fields and typos is valid, but that strictness could be handled with warn logs, rather than complete failure by default. In the rare case you want stop deserializing when it happens then that should be a config option.

Good to see other providers have realized this.

jackson/jackson3/MIGRATING_TO_JACKSON_3.md at main · FasterXML/jackson

Main Portal page for the Jackson project. Contribute to FasterXML/jackson development by creating an account on GitHub.

GitHub