Reconsider the default for DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES

283 views
Skip to first unread message

Pascal Gélinas

unread,
Jun 20, 2014, 11:17:36 AM6/20/14
to jackso...@googlegroups.com, in...@olivergierke.de
Continued from the github issue (https://github.com/FasterXML/jackson-databind/issues/493#issuecomment-46680797)

Yes, I do think it's right by default to fail: you should be very strict about what you accept by default, then gradually relax your constraint depending in the situation. If you change this default, should JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES be changed to true too to be "robust" to older Json generator? And what about DeserializationFeature.FAIL_ON_INVALID_SUBTYPE? These features are all configured by default to be very strict about what Json is accepted. Then, application code can relax those constraints.

With the specific case of ignoring properties, you can do it with different scope: be very specific JsonIgnoreProperties("foo") on a class, then a little bit larger with JsonIgnoreProperties(ignoreUnknown=true) on a class, then very wide with the feature to true. I think this ties in very well with how Java defined its access modifier: the "default" modifier is very strict (package-private), but it's also probably the modifier used the less.

We clearly don't develop the same kind of system and perhaps in your case it makes sense to always accept unknown properties. And from your twitter "survey", it seems that your circle also thinks the same thing, which is fine. I also enabled this feature for some cases I had, but I don't think Jackson defaults should cater to the majority, simply because the majority changes over time and who you talk to. The defaults should offer a consistent and strict definition of what is valid.

Tatu Saloranta

unread,
Jun 23, 2014, 1:09:22 AM6/23/14
to jackso...@googlegroups.com, in...@olivergierke.de
I was considering change to this default for 2.0, but in the end decided against that, to reduce number of changes since 1.x.

However, I agree with Pascal in that I do not think this should be changed. My reasoning is more due to backwards compatibility, and in absence of actual bug to fix I do not think it is right to change defaults in minor releases.
So if there is ever jackson 3 I think this change could be made, but I do not want a change in a 2.x update.

-+ Tatu +-



--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages