RUST-1933: Support deserializing $uuid extended JSON syntax #474
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the extended JSON deserializer to support the
$uuid
documented here. As noted in the ticket, this behavior now required for the Atlas SQL team. I confirmed locally that this change works for our purposes.Looking through the code, it seems
$uuid
is supported in several other places but not for directserde_json::from_str::<bson::Bson>
parsing. I assume this was an accidental omission and not a deliberate choice.I was unsure exactly where/how to test this. I spent a lot of time looking through the test files but I never quite figured out how/where/if you are testing this specific behavior (parsing extended json strings directly into
Bson
values), so I added a single, simple unit test to cover this. Let me know if testing should be done elsewhere or another way.Edit: To be clear, our actual use case is using
serde_yaml
to parse yaml files that contain extended json values. The files are parsed into structs that have nestedBson
fields, which is why this change is relevant and why we can't conveniently use the workaround of parsing into aserde_json::Value
and then usingTryFrom<serde_json::Value> for Bson
. I updated the description to be a bit more lax to make this clear.