-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Codecs
-
None
When the Mongo Java Driver deserializes BSON objects to POJOs it ignores fields that it does not recognize.
We are interested in a new feature that would enable throwing exceptions when unknown fields are found while deserializing using the PojoCodec. There is behavior analogous to this in the .NET driver.
It seems like there were a couple options discussed in the original POJO codec project when considering what to do when we find fields in documents that are not found in the Java POJO objects. Taken from that ticket, those were:
- (currently implemented) skipping that document field
- Throwing an exception
- Dumping extra fields to an optional BsonDocument on the object to hold the extra fields
Would you all consider an implementation that would (optionally) take approach (2) or (3)? We would be interested in submitting a PR if you agree that the functionality would be useful and worth adding.
- is related to
-
JAVA-2218 Handle mismatches between document fields and object fields
- Closed