builder.cpp 493 B

12345678910111213141516171819
  1. #include <iostream>
  2. #include "xbson/bson.h"
  3. using namespace std;
  4. int main(int argc, char *argv[]) {
  5. // use static so parse only once
  6. static xpack::BsonBuilder bd("{?:?, 'users':?}");
  7. cout<<"error:"<<bd.Error()<<endl;
  8. vector<int> v(3);
  9. v[0] = 1; v[1] = 2; v[2] = 3;
  10. cout<<"json1:"<<bd.EncodeAsJson("hi", true, v)<<endl;
  11. cout<<"json2:"<<bd.EncodeAsJson("uid", 123.0, "LiLei/HanMeimei/Jim")<<endl;
  12. cout<<"json3:"<<bd.EncodeAsJson("Lang", "C++", "")<<endl;
  13. }