C++ REST SDK 接続確認のpingでjsonをかえすときのresponseの確認
pplx::task<void> RequestJSONValueAsync() { // TODO: To successfully use this example, you must perform the request // against a server that provides JSON data. // This example fails because the returned Content-Type is text/html and not application/json. http_client client(L"http://133.34.174.246:5000/ping"); return client.request(methods::GET).then([](http_response response) -> pplx::task<json::value> { if (response.status_code() == status_codes::OK) { return response.extract_json(); } // Handle error cases, for now return empty json value... return pplx::task_from_result(json::value()); }) .then([](pplx::task<json::value> previousTask) { try { const json::value& v = previousTask.get(); // Perform actions here to process the JSON value... wcout << v << endl; } catch (const http_exception& e) { // Print error. wostringstream ss; ss << e.what() << endl; wcout << ss.str(); } }); /* Output: Content-Type must be application/json to extract (is: text/html) */ } int wmain() { /*std::wcout << L"Calling HTTPStreamingAsync..." << std::endl; HTTPStreamingAsync().wait();*/ wcout << L"Calling RequestJSONValueAsync..." << endl; RequestJSONValueAsync().wait(); getchar(); }
responseがvで帰ってくる