这是我的代码片段:
#include <json.hpp>
using json = nlohmann::json;
chat_message m; // helpter class to send the message
json j;
j["name"] = "States";
j["type "]= "Regular";
j["num"] = 4;
m.body_length( j.asString().size() ); // throws error on j.asString
我想将整个 JSON 对象更改j
为std::string
并将其发送到服务器。
如何将此对象转换为std::string
?
我尝试使用asString
. 我对这个 JSON 东西很陌生。