Details
Description
New to MongoDB. I have already install mongocxx-driver-3.2.0 successfully in my PC. But when i run my code as follows, this error happened:
the console outputs the invalid bson. What should i do to solve it?
int main() { |
bsoncxx::builder::stream::document stream_doc;
|
stream_doc << "_id" << 1 << "name" << open_document |
<< "first" << "John" << "last" << "Backus" << close_document |
<< "contribs" << open_array << "Fortran" << "AlGOL" << "Backus-Naur Form" << "FP" << close_array |
<< "awards" |
<< open_array
|
<< open_document
|
<< "award" << "W.W. McDowell Award" |
<< "year" << 1967 |
<< "by" << "IEEE Computer Society" |
<< close_document
|
<< open_document
|
<< "award" << "Draper Prize" |
<< "year" << 1993 |
<< "by" << "你好" |
<< close_document
|
<< close_array;
|
|
bsoncxx::document::view view = stream_doc.view();
|
std::cout << bsoncxx::to_json(view) << std::endl;
|
return 0; |
}
|