22 Star 67 Fork 23

xiaozhuai / cxxurl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
example_parse_json_body.cpp 840 Bytes
一键复制 编辑 原始数据 按行查看 历史
/**
* @author : xiaozhuai
* @date : 17/1/4
*/
#include <iostream>
#include <cxxurl/cxxurl_all.h>
#include <json.hpp>
using namespace std;
using namespace CXXUrl;
using nlohmann::json;
int main(int argc, char** argv){
stringstream ss;
json json;
Request request = RequestBuilder()
.url("http://localhost:3000/json")
.followLocation(true)
.contentOutput(&ss)
.build();
CURLcode res = request.get();
ss >> json;
cout << "------------ Code ------------" << endl
<< res << endl
<< "--------- Body Parsed --------" << endl
<< "project : " << json["project"].get<string>() << endl
<< "author : " << json["author"].get<string>() << endl
<< "repos : " << json["repos"].get<string>() << endl
<< flush;
}
C++
1
https://gitee.com/xiaozhuai/cxxurl.git
git@gitee.com:xiaozhuai/cxxurl.git
xiaozhuai
cxxurl
cxxurl
master

搜索帮助