Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-2097

BSON-serializer functions for user-defined objects

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None

    Description

      Like the epic JAVA-1812, we should consider providing an interface that allows users to define serializer functions that convert ordinary C++ objects to BSON objects.

      We'd have to allow both internal and external functions (relative to the namespace of the class) for users that want to amend source code they maintain and add serializers for ones they don't.

      For example, a user may wish to serialize a class:

      struct Person {
        std::string name;
        std::string address;
      };

      into the BSON object:

      {"name" : "bob", "address" : "123 My Street"}

      In which case, they should add methods in struct Person to do so.

      Alternatively, a user may wish to add a custom serializer function for the standard C++ container unordered_multimap. It would be impractical to add those functions to the std namespace. Therefore, we should consider how we'd handle this case. A suggestion would be to allow users to add functions to one of our namespaces.

      Attachments

        Activity

          People

            raymund.rodriguez@mongodb.com Raymund Rodriguez
            clyde.bazile@mongodb.com Clyde Bazile III (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: