Skip to content

to_document(): numbers now serialized to serde_json::private::number? #611

@Theodlz

Description

@Theodlz

Versions/Environment

  1. What version of Rust are you using? rustc 1.89.0-nightly (be19eda0d 2025-06-22)
  2. What operating system are you using? MacOS
  3. What versions of the driver and its dependencies are you using? (Run
    cargo pkgid mongodb & cargo pkgid bson) mongodb==3.3.0, bson==2.15.0
  4. What version of MongoDB are you using? (Check with the MongoDB shell using db.version()) 8.0.11
  5. What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)? standalone

Describe the bug

With mongodb==3.2.5 which used bson==2.14.0, when I called mongodb::bson::to_document on a serde Value that contains numerical values (e.g. {"$round": ["$candidate.magpsf", 2]}), the resulting Document looks very much like it's input serde_json Value, which btw I created from a string, read with serde_json::from_str::<serde_json::Value>(string_value). But now, instead all numerical values (like the 2 in that example I provided) are instead a Document of their own that looks like Document({"$serde_json::private::Number": String("2")}).

I guess I'm trying to understand where something changed for that to happen, and why? It makes it a lot harder to read documents created from serde_json::Values. Perhaps this change happened in serde_json and not here? I haven't figured that out yet.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions