Http::HttpResponse response; Http::HttpClient client; Http::HttpRequest request("post", url); std::string code = pCfg->code; request.addField("code", code); if (!client.execute(&request, &response)) { //TODO错误执行 } std::string body = response.getBody(); client.killSelf();
Json 请求解析
1 try 2 { 3 Json::Reader reader; 4 Json::Value root; 5 if (!reader.parse(body, root))//复制 6 { 7 //TODO 错误执行 8 } 9 std::string str = root.get("status", "").asString(); //得到值,但注意,adS 10 Json::Value mem = root.get("payload", ""); 11 if(mem..isArray()) 12 { 13 //TODO 14 } 15 } 16 catch(...) 17 { 18 //TODO 错误执行 19 }