[SERVER-2183] Using C++ and BSON, how do I serialize a key/value style container like map or unordered_map Created: 06/Dec/10 Updated: 12/Jul/16 Resolved: 16/Jan/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | MediaMath Mongo | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: |
| Description |
|
There are overloaded << operators for serializing an std::vector and std::list into a BSONObjBuilder but none for containers that have key value pairs. I understand that all mongo arrays are really key/value pairs that simply default to "0", "1", "2", etc for the keys if you treat them as simple arrays. Could you provide an example of how I might serialize an STL map into a BSONObjBuilder? |
| Comments |
| Comment by whoward [ 08/Apr/11 ] |
|
Doh! Thanks. Walt – |
| Comment by Mathias Stearn [ 06/Dec/10 ] |
|
BSONObjBuilder b BSONObj obj = b.obj() |