Support (de)serialization between BSON and EJSON

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • Fully Compatible
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Vesko Karaganev
            Reporter:
            Henri Nikku
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: