如何在http_request内发送 JSON 对象以及如何在服务器上访问它
How to send JSON object inside the http_request and how to access it on the server?
我用C++ REST SDK(卡萨布兰卡)创建了一个侦听器。我需要创建一个 http 服务器,它应该读取嵌入在请求消息正文中的 JSON 对象。如何实现这一点?我试图通过 Put 方法做到这一点。但是我找不到提取请求消息正文的方法。如果我可以在 put 方法中将该 json 对象转换为字符串以便打印它,那就更好了。但我找不到办法做到这一点。有没有可能的方法可以访问该 json 对象并将其转换为字符串?
这是我正在尝试的方法。
void WsListener::handle_put(http_request message)
{
cout << message.body.extract_json();
};
void WsListener::handle_put(http_request message)
{
pplx::task<utility::string_t> body_json = message.extract_string();
std::string jsonstr= utility::conversions::to_utf8string(body_json.get());
cout << jsonstr << endl;
};
http://microsoft.github.io/cpprestsdk/classweb_1_1http_1_1http__request.html#a0cd0f1c49cab39210517925a3644db1f
相关文章:
- 用于解析 win64 堆栈跟踪的命令行客户端(可以访问符号服务器)
- 如何使用 libCurl 将访问令牌发送到服务器 API
- mysql c ++连接器异常:用户"root"@'localhost'的访问被拒绝(使用密码:NO)&&MySQL服务器已消失
- 使用简单的 Indy 服务器代码进行访问冲突
- 接收音频块的异步TCP服务器会出现访问违规错误
- 使用QtCreator,如何在我有权访问ssh的远程服务器上构建我的项目?
- boost/asio:非常简单的聊天服务器无法访问收到的消息
- 连接到 FTP 服务器并访问文件
- 如何在http_request内发送 JSON 对象以及如何在服务器上访问它
- C 和Java,SQLite服务器同时访问
- 从未通过 C# 注册C++ COM 服务器访问 COM 接口
- 带有Corbaloc访问的Mico Corba服务器
- CORBA客户端是否有访问服务器IOR文件的方法
- 如何在Linux上使用Qt5访问远程MySQL服务器
- 如果我访问该页面,带有casablanca的http服务器将崩溃
- 当服务器不可访问时,curl_easy_performer返回-1
- 无法从我的二进制文件访问远程服务器中的数据库
- 分叉服务器,单个文件 - r/w 访问
- 提升连接后从TCP服务器访问TCP客户端IP地址+端口
- 如何使.cpp文件充当可访问的服务器