将 json/xml/bson 转换为 c++ 结构
libbson-1.0,需自行安装。未经充分测试,具体请参考READMElibmysqlclient-dev,需自行安装。未经充分测试…
C++ #include #include "xpack/json.h"
using namespace std;
struct Test { long uid; string name; XPACK(A(uid, "id"), O(name)); // "uid"的别名是"id" };
int main(int argc, char *argv[]) { Test t; string json="{"id":123, "name":"Pony"}";
xpack::json::decode(json, t);
cout
#include #include "xpack/json.h"
using namespace std;
/* struct timeval { time_t tv_sec; suseconds_t tv_usec; }; */
// timeval is thirdparty struct XPACK_OUT(timeval, O(tv_sec, tv_usec));
struct T { int a; string b; timeval t; XPACK(O(a, b, t)); };
int main(int argc, char *argv[]) { T t; T r; t.a = 123; t.b = "xpack"; t.t.tv_sec = 888; t.t.tv_usec = 999; string s = xpack::json::encode(t); couthello`也可以解析成功
static void decode(MYSQL_RES *result, T &val)static void decode(MYSQL_RES *result, const std::string&field, T &val)暂无开放 Issues,或尚未同步最近议题。