-
Type: New Feature
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
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.