Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4789

Support Map stringification in EJSON

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • bson-5.1.0
    • Affects Version/s: None
    • Component/s: EJSON
    • Labels:
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Details

      In the BSON library our EJSON stringifiy method defers to JSON.stringify for JS Map serialization which doesn't support inspecting the keys internal to a Map. We should add support that mirrors the support in BSON to fetch the key value pairs out of a Map and turn it into a JSON string.

      Non-string keys should throw an error.

      NODE-4122 Is related, fixing the replacer logic would likely make adding map support straight forward. (if map -> Object.fromEntries(map))

      AC

      • EJSON.stringify will turn Maps into the typical curly braced key value pair sequence of a JSON object
      • Add tests equivalent to our BSON map usage

            Assignee:
            warren.james@mongodb.com Warren James
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: