This ticket is about adding support to MQL for working with Extended JSON values.
Extended JSON
The MongoDB Extended JSON is a string format for representing BSON documents.
It allows for values of BSON-only types to be represented in standard JSON.
See the specification document which contains a conversion table, mapping value representations.
Excerpt from that table:
| BSON 1.1 Type or Convention | Canonical Extended JSON Format | Relaxed Extended JSON Format |
|---|---|---|
| Int32 | {"$numberInt": }} < 32-bit signed integer as a string > { | integer |
| Int64 | {"$numberLong": }} < 64-bit signed integer as a string > { | integer |
| Double [finite] | {"$numberDouble": }} < 64-bit signed floating point as a decimal string > { | non-integer |
| Double [non-finite] | {"$numberDouble": }} < One of the strings: {{{}"Infinity", "-Infinity", or "NaN". > } | < Same as Canonical Extended JSON > |
| ... |
Existing EJSON support
The embedded JS engine does not have functions for working with EJSON.
The bson NodeJS library has support for working with EJSON.
EJSON.serialize() takes an object and transforms all native/BSON types based on the mapping defined by Extended JSON. When that object is serialized to JSON, that result is an Extended JSON string.
EJSON.deserialize() takes an object describing the structure defined by Extended JSON and transforms it into an object containing native/BSON types.
This is available in the mongosh.
Proposal
The proposal is to add MQL expressions which work similarly to these JavaScript APIs. These expressions will be able to be combined with $convert to parse JSON, transform the Extended JSON values into native BSON values and back.
- is depended on by
-
COMPASS-10179 Investigate changes in SERVER-107499: Support (de)serialization between BSON and EJSON
-
- Needs Triage
-
- is related to
-
SERVER-115112 Complement EJSON conversion tests with the existing BSON test corpus
-
- Backlog
-
- split to
-
SERVER-114519 Support $serializeEJSON and $deserializeEJSON in SBE
-
- Needs Scheduling
-