hi ,
i am working with c++ rest sdk and wrote the following code:
pplx::task<void> RequestJSONValueAsync()
{
http_client client(L"http://www.mapquestapi.com/traffic/v2/incidents?key=Fmjtd%7Cluub2duy20%2Cb0%3Do5-9u2su4&callback=handleIncidentsResponse&boundingBox=43.050974,-106.601157,42.648250,-106.051840&filters=construction,incidents&inFormat=kvp&outFormat=json");
return client.request(methods::GET).then([](http_response response) -> pplx::task<json::value>
{
if(response.status_code() == status_codes::OK)
{
return response.extract_json();
}
return pplx::task_from_result(json::value());
})
.then([](pplx::task<json::value> previousTask)
{
try
{
json::value v = previousTask.get();
wcout<<v;
}
catch (const http_exception& e)
{
wostringstream ss;
ss << e.what() << endl;
std::wcout << ss.str();
}
});
}
int wmain()
{
std::wcout << L"Calling RequestJSONValueAsync..." << endl;
RequestJSONValueAsync().wait();
_getch();
}
in the follwing code the data return by http request is of the type json::value. But it is giving some error.
and if i am taking it as type wstring than I am able to receive the data.
can you suggest me a way how to receive the data in json::value format.
Thanks