[JAVA-3353] Document and BasicDBObject toJson methods move the _id field to the first key Created: 11/Jul/19  Updated: 28/Oct/23  Resolved: 24/Jul/19

Status: Closed
Project: Java Driver
Component/s: JSON
Affects Version/s: None
Fix Version/s: 3.11.0

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: John Stewart (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related

 Description   

They both do this by calling EncoderContext.isEncodingCollectibleDocument(true).

BsonDocument#toJson, inconsistently, does not do any re-ordering.

I think the current behavior is wrong, as there are situations where this reordering is incorrect, e.g. for MongoDB index specifications.



 Comments   
Comment by Githook User [ 24/Jul/19 ]

Author:

{'name': 'John Stewart', 'username': 'jstewart-mongo', 'email': 'john.stewart@mongodb.com'}

Message: JAVA-3353: update Document#toJson test
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/6328315f335fac25e8dd8a913cc0f2577004aa24

Comment by Githook User [ 24/Jul/19 ]

Author:

{'name': 'John Stewart', 'username': 'jstewart-mongo', 'email': 'john.stewart@mongodb.com'}

Message: Avoid reordering of _id field in Document and BasicDBObject

JAVA-3353
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/77e5c021438b6c6f5598e273812a25d43840889b

Generated at Thu Feb 08 08:59:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.