Operation of the Bson
Flyfish 2015-8-27
It's bson-cpp.
Creation of Bson
//{name: ' Joe ', age:33.7} //Mode 1Bson:: BoA=Bson:: Bob().Append"Name","Joe").Append"Age",33.7).obj ();//Mode 2Bson:: BobX X.Append"Name","Joe"); X.Append"Age",33.7); Bson:: BoB=X.obj ();//Mode 3Bson:: BoC=BSON ("Name"<< "Joe" <<"Age"<<33.7);//Nested modeBson:: BoD=BSON ("x" << "1" << "Y" << true << "Subobj" <<BSON ("M" << 3 << "n" << 4) );
output of the Bson
Output mode1c["Name"] C["Age"]//Output Mode 2 for(Bson::bo::iteratorit(c);it. more (); ) {strings=it. Next (). ToString (); }//Output mode 3 for(Bson::bo::iteratorit=c.begin ();it. More ();) {Bson::be t=it. Next ();stringS=t.fieldname ();//The output is Age,name if(T.type () = = bson::string) {T.VALUESTR ();//Output Joe}Else if(T.type () = = bson::numberdouble) {T._numberDouble ();//Output 33.7} }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Operation of the Bson