Skip to content

RUST-2174 feat(extjson): parse legacy {"$date": <ms since epoch>} #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2025

Conversation

xiangjinwu
Copy link
Contributor

According to the specification, there exists a legacy Extended JSON form of Datetime
https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md#datetime

Mongoexport 2.4 and the Java driver always transform a Datetime object into an Extended JSON string of the form {"$date": <ms since epoch>}. This form has the problem of a potential loss of precision or range on the Datetimes that can be represented.

Specially, this legacy form is called JsonMode.STRICT in the Java JsonWriterSettings, while the canonical form is JsonMode.EXTENDED. The former is still used by the Debezium connector for MongoDB.

This PR adds the ability to parse such legacy format, without conflicting with the standard ones.

@abr-egn abr-egn self-assigned this Mar 10, 2025
@abr-egn abr-egn changed the title feat(extjson): parse legacy {"$date": <ms since epoch>} RUST-2174 feat(extjson): parse legacy {"$date": <ms since epoch>} Mar 10, 2025
@abr-egn abr-egn merged commit 8cf62fc into mongodb:main Mar 10, 2025
6 of 11 checks passed
@abr-egn
Copy link
Contributor

abr-egn commented Mar 10, 2025

Thank you for the contribution! The CI failures were unrelated and this was a straightforward addition, so I've merged it in and it'll go out in the next release (should happen in the next week or so).

@xiangjinwu xiangjinwu deleted the extjson-date-java-legacy branch March 25, 2025 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants