Reputation: 9522
Say we have a string with binary bson data inside. How to load it into bson object?
Upvotes: 0
Views: 1989
Reputation: 1
For raw json string use mongo::fromjson
mongo::BSONObj object = mongo::fromjson("{"Login":"test","Password":"12345","Role":["admin","manager"]}");
Upvotes: 0
Reputation: 4791
I think there's an example to do just that on that same page:
BSONObjBuilder b;
b << "name" << "Joe" << "age" << 33;
BSONObj p = b.obj();
That is, BSONObjBuilder
has a stream operator for const char *
.
BSONObjBuilderValueStream & operator<< (const char *name)
Stream oriented way to add field names and values.
Upvotes: 1