Skip to content

RUST-677 Serialization formatting options #230

Open
@AlexKovalevych

Description

@AlexKovalevych

After retrieving data from database like:

use mongodb::bson::from_document;

let data = from_document::<Value>(bson_document)?;

I'm not able to serialize data to json with custom datetime format getting datetime fields like:

...
        "updated_at": {
          "$date": "2021-02-01T14:50:01.504Z"
        },
...

I can't use serde helpers, since i don't know the data schema. The only solution i see right now is to manually iterate all fields in bson_document recursively and in case of Bson::DateTime type convert it to Bson::String type with desired datetime format. Is there a better solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    tracked-in-jiraTicket filed in Mongo's Jira system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions