You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What versions of the driver and its dependencies are you using? (Run cargo pkgid mongodb & cargo pkgid bson)
What version of MongoDB are you using? (Check with the MongoDB shell using db.version())
What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?
Describe the bug
A clear and concise description of what the bug is.
The Code I'm using to test this looks like this:
#[test]
fn test_bson_datetime_parsing() {
let dt = bson::DateTime::now();
let s = dt.to_string();
let iso = dt.try_to_rfc3339_string().unwrap();
let doc = doc!{ "time": dt };
let json = json!({"time": dt});
println!("df: {dt}, s: {s}, iso: {iso}, doc: {doc}, json: {json}");
let iso_string = "2024-04-05T19:24:00.408Z";
let json_str = format!(
r#"{{
"time": {{"$date" : {{"$numberLong":"{}"}} }}, "id": "{}"
}}"#,
"1674504029491", "390f5f21-631a-463d-88a5-ebc29ca8a6e3"
);
let parsed: BsonTester = serde_json::from_str(&json_str).unwrap();
println!("{}", parsed.time.unwrap().try_to_rfc3339_string().unwrap())
}
```
But the main issue is that I want the user to be able to see a json object like:
```json
{
"time": "2024-04-05T19:24:00.408Z"
}
And this could then be deserialized with serde_json automatically with a struct like this:
Versions/Environment
cargo pkgid mongodb
&cargo pkgid bson
)db.version()
)Describe the bug
A clear and concise description of what the bug is.
The Code I'm using to test this looks like this:
And this could then be deserialized with serde_json automatically with a struct like this:
That way the client doesn have to deal with this mess of $date { $numberLong } when sending data to or from the web server
The text was updated successfully, but these errors were encountered: