jansupol / jsonbapi

0 stars 0 forks source link

Any way to globally opt-out of JSONB's "Must-Ignore" policy? #56

Open jansupol opened 6 years ago

jansupol commented 6 years ago

I am attempting to change the implementation of some code to use JSON-B instead of Jackson. In the process of doing so, I would like to match behavior so existing users are not impacted. One key behavior difference I have found is during deserialization Jackson will reject unrecognized properties, whereas JSON-B will simply ignore unrecognized properties.

I was looking around the API for a way to reject unrecognized properties (ideally via JsonbConfig). I posted this question on SO, but eventually I ran across this section of the JSON-B spec:

3.18 Must-Ignore policy When JSON Binding implementation during deserialization encounters key in key/value pair that it does not recognize, it should treat the rest of the JSON document as if the element simply did not appear, and in particular, the implementation MUST NOT treat this as an error condition.

So this explains why the default behavior is the way it is... but is there any way to opt-out of this? It would be a key part of migrating existing applications from Jackson to JSON-B.

jansupol commented 6 years ago
jansupol commented 6 years ago

@m0mus Commented Adding it to version 2.0 proposed features.