小编Ams*_*Ams的帖子

将 Json 对象转换为字符串

这是我的代码片段:

#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
Run Code Online (Sandbox Code Playgroud)

我想将整个 JSON 对象更改jstd::string并将其发送到服务器。

如何将此对象转换为std::string
我尝试使用asString. 我对 JSON 很陌生。

c++ json

1
推荐指数
1
解决办法
9661
查看次数

标签 统计

c++ ×1

json ×1