1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| std::string strMsg = R"({ "user" :"test", "status":"login", //登录状态:login、logout "result":"1", //登录和登出结果,1表示成功,0表示失败 "reason":"", //原因,比如超时退出,准入策略限制导致登录失败等 "token":"xxx" //token内容 })";
std::string strMsg_empty = ""; Json::object jstest = Json::object{}; string err; const auto json = Json::parse(strMsg_empty, err, JsonParse::COMMENTS);
jstest["msgtype"] = "test"; jstest["data"] = (json);
Json json1 = Json(jstest); std::cout << json1.dump();
const Json obj = Json::object({ { "msgtype", "TEST" }, { "data", json }, });
std::cout << obj.dump() << std::endl;
|