Skip to content

Timestamp serialized in a wrong way #168

@zhangyaoxing

Description

@zhangyaoxing

With the legacy shell, the Timestamp is correctly serialized by JSON.stringify

JSON.stringify(new Timestamp(1765119887, 0))
// {"$timestamp":{"t":1765119887,"i":0}}

But with mongosh, the behavior of this method is changed:

JSON.stringify(new Timestamp(1765119887, 0))
{"$timestamp":"7581132188184215552"}

To make it backward compatible, we can use EJSON.stringify with a replacer the make sure the output is the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions